Posted By

dsntos on 08/18/09


Tagged

php directory


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Reasttou
umang_nine
BrianCoyDesign


List Directory Contents


 / Published in: PHP
 

URL: http://webdeveloperplus.com/php/21-really-useful-handy-php-code-snippets/

  1. function list_files($dir)
  2. {
  3. if(is_dir($dir))
  4. {
  5. if($handle = opendir($dir))
  6. {
  7. while(($file = readdir($handle)) !== false)
  8. {
  9. if($file != "." && $file != ".." && $file != "Thumbs.db")
  10. {
  11. echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n";
  12. }
  13. }
  14. closedir($handle);
  15. }
  16. }
  17. }

Report this snippet  

You need to login to post a comment.