Lister tous fichiers contenus dans un dossier


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

php list all files of a given directory


Copy this code and paste it in your HTML
  1. <?php
  2. //The second example shows how to retrieve only the files
  3. //contained in a given path.
  4.  
  5. $filelist = array();
  6. if ($handle = opendir(".")) {
  7. while ($entry = readdir($handle)) {
  8. if (is_file($entry)) {
  9. $filelist[] = $entry;
  10. }
  11. }
  12. closedir($handle);
  13.  
  14. }
  15. print_r ($filelist);
  16. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.