July 17, 2016
List files and directories inside the specified path in PHP

Hi, friends in this tutorial I show you how to list files and directories inside the specified path in PHP. A simple request is to be able to provide a list of some or all of the files in a directory. Using the while loop, we list out all the files from the directories.
index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<?php $msg = ""; if($handle = opendir('.')){ while (false !== ($file = readdir($handle))) { if (($file != ".") && ($file != "..")) { $msg .= '<li><a href="'.$file.'">'.$file.'</a></li>'; } } closedir($handle); } ?> <!doctype html> <html> <head> <title>SoftAOX | List files and directories inside the specified path in PHP</title> </head> <body> <h2>List files and directories inside the specified path in PHP</h2> <p>List of files:</p> <ul> <p> <?php echo $msg ?> </p> </ul> </body> </html> |
Download
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]