$handle=opendir("."); // open the current directory
$handle=opendir("E:\\my_dir\\"); // OR use the path
while (($file = readdir($handle))!==false) {
echo "$file <br>";
}
closedir($handle);
Many times we have to display the list of files in a directory. We can keep the script in any location and by using the file path we can display the files inside the directory. opendir()
:readdir()
:closedir()
:$path='images/';// change the path here related to this page
$handle=opendir($path);
while (($file = readdir($handle))!==false) {
if(strlen($file)>3){echo "<img src=$path$file> <br>";}
}
closedir($handle);
You can also list the files and directories by using dir function scandir() 06-07-2021 | |
Superb |