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>”;




Share This Post

Post Comment