Directory lister - Totally PHP


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. ?>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.