List folder content


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



Copy this code and paste it in your HTML
  1. <?php
  2. //folder you want to list
  3. $path=".";
  4. //extension you don't want to list
  5. $no_mostrar=Array("","php");
  6.  
  7. $dir_handle = @opendir($path) or die("Error Opening $path");
  8. while ($file = readdir($dir_handle)) {
  9. $pos=strrpos($file,".");
  10. $extension=substr($file,$pos);
  11. if (!in_array($extension, $no_mostrar)) {
  12. echo "<a href=\"$file\" id=\"enlace_$file\" title=\"$file\">$file</a><br />";
  13. }
  14.  
  15. }
  16. closedir($dir_handle);
  17. ?>

URL: http://xhiena.net/index/php-mostrar-contenido-directorio/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.