Page 1 of 1

Displaying files, but hiding subdirectories

Posted: Sat Dec 27, 2003 1:16 am
by tristanlee85

Code: Select all

<?php
$folder = "\\saturnspot";
$link = 'http://24.197.74.135/saturnspot';
if ($handle = opendir($folder)) { 
   while (false !== ($file = readdir($handle))) { 
       if ($file != "." && $file != "..") { 
           echo "<a href="http://24.197.74.135/saturnspot/$file">$file</a><br><br>"; 
       } 
   } 
   closedir($handle); 
} 
?>
With this, it shows all files and folder in the folder specified. How do I display only files and hide the folders?

Posted: Sat Dec 27, 2003 2:00 am
by Weirdan

Code: Select all

//....[skipped]....
      if ($file != "." && $file != ".." && !is_dir($folder.$file)) {
//....[skipped]....

Posted: Sat Dec 27, 2003 2:40 am
by tristanlee85
Ahh, thank you.