Display file list within Folder


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



Copy this code and paste it in your HTML
  1. <?PHP
  2.  
  3. $folder = "myFolderName/";
  4. $handle = opendir($folder);
  5.  
  6. # Making an array containing the files in the current directory:
  7. while ($file = readdir($handle))
  8. {
  9. $files[] = $file;
  10. }
  11. closedir($handle);
  12.  
  13. #echo the files
  14. foreach ($files as $file) {
  15. echo "<a href=$folder$file>$file</a>"."<br />";
  16. }
  17. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.