title: Listing out files in PHP (ONLY the files) as links from all subdirectories of a directory
body: <p>I have a ftp site that hosts several files.  Each file is in its own folder by itself in the main directory (uploads), due to restrictions in place by the downloading software we are using (each file must have a unique filepath, and the file name has to be modpack.zip (cannot be any variation of this name, has to have that exact name, hence why each version is in its own subfolder)</p>
  
  <p>I need to find a way to list all the files from all subdirectories of the main upload folder in a table, as well as list how big each file is.  Each file must have a link to it, and the folders do not need to be listed.</p>
  
  <p>The code I have so far as my starting point is:</p>
  
  <pre><code>&lt;div id="list"&gt;&lt;table&gt;
  &lt;tr&gt;&lt;td align="center"&gt;Modpack List&lt;/td&gt;&lt;/tr&gt;
  &lt;?php
  
  $dir_open = opendir('uploads/');
  
  while(false !== ($filename = readdir($dir_open))){
      $bytes = filesize($_SERVER['DOCUMENT_ROOT']."/uploads/".$filename."");
      if($filename != "." &amp;&amp; $filename != ".."){
          echo '&lt;tr&gt;&lt;td&gt;&lt;a href="/uploads/'.$filename.'"&gt;'.$filename.'&lt;/a&gt; - '.bytesToSize($bytes).'&lt;/td&gt;&lt;/tr&gt;';
      }
  }
  
  closedir($dir_open);
  
  ?&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have tried using readdir() and scandir(), but both list both the files and subfolders, which I don't want, and the current setup only list any files and folders directly under /uploads, and won't list any of the files under the subfolders unless I click the folder, which takes me to an FTP page for that folder.</p>
  
  <p>I have tried several posted solutions I saw on here, as well as on other sites, but none of which did what I need, and I can't figure out how to make it omit the folders as links, and only list the files.</p>