Posted By

jprochazka on 10/02/10


Tagged


Versions (?)

Get a directory listing.


 / Published in: PHP
 

List files within a directory while ignoring system folders such as "Thumbs.db" as well as "." and "..".

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

Report this snippet  

You need to login to post a comment.