Posted By

nveselinov on 10/12/10


Tagged

php view list file folder directory


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

cjmling
tspitzr


PHP list directory


 / Published in: PHP
 

  1. <?php
  2. $dir = opendir(".");
  3. while($entryName = readdir($dir)){
  4. $dirArray[] = $entryName;
  5. }
  6. closedir($dir);
  7. $indexCount = count($dirArray);
  8. echo $indexCount." Files<br />";
  9. for($index=0; $index < $indexCount; $index++){
  10. if($dirArray[$index] != "." && $dirArray[$index] != ".."){
  11. $type = filetype($dirArray[$index]);
  12. if($type == "dir") {
  13. echo "<img src='img/dir.png'>";
  14. } else {
  15. echo "<img src='img/file.png'>";
  16. }
  17. echo "<a href='".$dirArray[$index]."'>".$dirArray[$index]."</a><br />";
  18. }
  19. }
  20. ?>

Report this snippet  

You need to login to post a comment.