
<?
//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);
?>
One of the questions people have asked is how to not display the double dots and single dots. This can be done by modifying the while loop and replacing it with:
while ($file = readdir($dir_handle))
{
if($file!="." && $file!="..")
echo "<a href='$file'>$file</a><br/>";
}
Not to hard was it? If you have any questions,e-mail us at webmaster@spoono.com. You can see my code that I worked on and made sure worked by right clicking and saving list.txt.
Copyright © 2000-2008 Spoono, LLC. All rights reserved.
Network: Reseller Web Hosting by Spoono Host | Spoonloads | Absolute Cross
Terms of Service | Privacy Policy.