Quick Search:
 
 PHP Code: Directory Listing Jump to:  
Category: >> PHP Code >> Directory Listing  

<< lastnext >>

Snippet Name: 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.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: February 27th, 2009

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


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org