PHP listing files in folder
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
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