Don't show directories script!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Don't show directories script!!!

Post 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); 
}
}
 




?>
User avatar
Skywalker
Forum Contributor
Posts: 117
Joined: Thu Aug 29, 2002 3:33 am
Location: The Netherlands

Post by Skywalker »

Yes that was the trick :P thx
Post Reply