Page 1 of 1

Don't show directories script!!!

Posted: Thu Sep 04, 2003 12:59 pm
by Skywalker
I have a script that read al the files out of the base directory, but it also reads the sub directories, that is the thing i don't want, i want only to see the files and not the sub directories. Can somebody with this code belowe.

I allready spend 2 hours searching for a selution, but it seams god is not helping today :P

Code: Select all

<?php

if ($handle = opendir('')) {
   echo "Download Files:<br>";


   /* This is the correct way to loop over the directory. */
   if ($handle = opendir('.')) {
   while (false !== ($file = readdir($handle))) { 
        if (is_dir ($file != "." && $file != "..")) { 
            echo "<a href="$file">$file\n<br>"; 
        } 
    }
   closedir($handle); 
}
}
 




?>

Posted: Fri Sep 05, 2003 7:50 am
by Skywalker
Yes that was the trick :P thx