Reading Contents from a Directory : Directory « File Directory « PHP






Reading Contents from a Directory


 <?php
  if (file_exists ("./")) {
    if (is_dir ("./")) {
      $dh = opendir ("./") or die (" Directory Open failed !");
      while ($file = readdir ($dh)) {
        echo "$file\n";
      }
      echo "Directory was opened successfully";
      Closedir ($dh);
    }
  }
 ?>
           
       








Related examples in the same category

1.Listing the Contents of a Directory with readdir()
2.Calculate the size for a directory
3.readdir: Read entry from directory handle
4.scandir: List files and directories inside the specified path
5.The current working directory
6.Print all files under a directory
7.Read the content from a directory
8.Clean Path by Regular Expressions