Posted By

andyhartleeds on 10/02/07


Tagged


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

vali29
hudge
skywalker
helloyj
JimiJay
carlosabargues
ninjacharlee
sbcjr
clacwebstudio


Directory lister - Totally PHP


 / Published in: PHP
 

URL: http://www.totallyphp.co.uk/scripts/directory_lister.htm

  1. <?
  2.  
  3. /**
  4.  * Change the path to your folder.
  5.  *
  6.  * This must be the full path from the root of your
  7.  * web space. If you're not sure what it is, ask your host.
  8.  *
  9.  * Name this file index.php and place in the directory.
  10.  */
  11.  
  12. // Define the full path to your folder from root
  13. $path = "/home/user/public/foldername/";
  14.  
  15. // Open the folder
  16. $dir_handle = @opendir($path) or die("Unable to open $path");
  17.  
  18. // Loop through the files
  19. while ($file = readdir($dir_handle)) {
  20.  
  21. if($file == "." || $file == ".." || $file == "index.php" )
  22.  
  23. continue;
  24. echo "<a href=\"$file\">$file</a><br />";
  25.  
  26. }
  27.  
  28. // Close
  29. closedir($dir_handle);
  30.  
  31. ?>

Report this snippet  

You need to login to post a comment.