how to fetch all files from folder using php

PHP directory listing

Some times we have to display the list of all files in a directory.We can do this with the help of php function readdir(). The code to display all the files is given blow.

$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);


To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

Share This Post

Related Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie