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


while (($file = readdir($handle))!==false)




echo “<img src=$path$file> <br>”;




Bansal Sumit

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *