Hi All
I have the following code which populates a list box with the names of folders within a folder that I specify as the root. However, my code is only displaying one level of folders within my root folder and I need it to display all sub folders within those folders (i hope that makes sense).
Here is my current code:
$path = "../mydocs/";
$dir_handle = @opendir($path) or die("Unable to open $path");
while (false !== ($file = readdir($dir_handle))) {
if ($file == ".." || is_file($file))
continue;
if ($file == ".") {
$file = "/";
}
echo " <option value=\"$file\">$file</option>\n";
}
closedir($dir_handle);
Would someone be able to help me greatly by inserting code which will display the sub folders also?
I guess what I am looking for is my list box to look something like this when expanded:
/
/Level1
/Level1/sublevel1
/Level2
/Level2/sublevel2
/Level2/sublevel2/anotherfolder
Many Thanks for any help offered.