Darren,
Thanks for the ideas.
- How would I use error handling in this situation?
I am still new to php and found one script but it didn't really work.
My script goes in read the directory and then procedes to open directory. I get errors when the directory can't be opened.
Here is my script.$basedir = "/home/"; // Base directory
function listall($dir)
{
// Initialize temporary arrays for sorting
$dir_files = $dir_subdirs = array();
// Print current directory
print( "<ul>");
print( "<li><b>$dir</b>\n");
// Change to directory
chdir($dir);
// Open directory;
if ($dir == "/home/ahumphre/") {
print ("this is allans special directory");
}
else {
$handle = @opendir($dir);
}
// or die( "Directory \"$dir\"not found.");
// Loop through all directory entries, construct
// two temporary arrays containing files and sub directories
while($entry = readdir($handle))
{
if(is_dir($entry) && $entry != ".." && $entry != ".")
{
$dir_subdirs[] = $entry;
}
elseif($entry != ".." && $entry != ".")
{
$dir_files[] = $entry;
}
}
// Sort files and sub directories
sort($dir_files);
sort($dir_subdirs);
// Print all files in the curent directory
for($i=0; $i<count($dir_files); $i++)
print( "<li>$dir_files[$i]\n");
}
// Traverse sub directories
for($i=0; $i<count($dir_subdirs); $i++)
{
listall( "$dir$dir_subdirs[$i]/");
}
print( "</ul>");
// Close directory
closedir($handle);
}
listall($basedir);
?>
Thanks in advance for your help!
Heather