Grabbing Folder Names
Posted: Tue Oct 29, 2002 2:02 pm
Hello Everyone! is there a way to get the names of all the folders in a specified directory?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?
$current_dir="/usr/local/apache/htdocs/"; // full server path to folder
$dir=opendir($current_dir); // open directory of the folder
$testurl="http://www.stevesand.com/"; // URL of folder to access
echo "<hr>"; // horizontal rule inserted
while ($file=readdir($dir)) // begins to read directory
{
if ($file =="." || $file == ".." || $file =="index.html")continue; // filter files
if (is_file($file))
{
echo "<br>"
."<a href="$testurl$file">$file</a><br>"; //inserts link - - URL address + file
}
}
echo "<p><hr><br>"; // horizontal rule
closedir($dir); // close the directory of the folder
?>