Directory Listing

Description: A simple script that lists all the items in the directory including folders and files and also makes a link to them.

<?PHP
 
//define the path as relative
$path = "/home/yoursite/public_html/whatever";
 
//using the opendir function
$dir_handle = @OPENDIR($path) or DIE("Unable to open $path");
 
ECHO "Directory Listing of $path<br/>";
 
//running the while loop
WHILE ($file = READDIR($dir_handle)) {
        ECHO "<a href=$file>$file</a><br/>";
}
 
//closing the directory
CLOSEDIR($dir_handle);
 
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.