Share on Google+Share on Google+

PHP listing files in folder

Advertisement
In this tutorial we will learn how to list all files present in the folder. In the example we will show it with the use of readdir() function

  • All files, folder   of the given folder can be listed.
  • Function readdir() takes input as the folder handle.
  • Then readdir() returns the name of all the files and folders.


Example of PHP Listing Files in Folder
<?php
     $file
=opendir("c:\apache-maven-2.1.0-bin");
     do
    
{
     echo
$a."<br>";
      }
     while
($a=readdir($file));
?>


Output
.
..
bin
boot
conf
lib
LICENSE.txt
NOTICE.txt
README.txt

Advertisements

Posted on: November 2, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.