List content of directory


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



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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.