clickable directory listing in HTML
Posted: Thu Aug 21, 2003 10:32 am
Hi there:
Here is the code for listing the directory - but would like to expand each directory only when clicked
Any help on this will be much aprreciated
Thanks
Biju
<?
function directory_tree($address){
$exts = array("vbs", "js");
$dir = opendir($address);
if(!$dir){
return 0;
}
print "<ul>\n";
while($entry = readdir($dir)){
if(is_dir("$address/$entry") && ($entry != ".." && $entry !="." && $entry !=='icons' && $entry !=='hidden')){
print "<li><a href='$_SERVER[PHP_SELF]?expand=$address/$entry'>$entry</a>\n";
directory_tree("$address/$entry");
}else{
for ($i = 0; $i < count($exts); $i++){
if (eregi("\.". $exts[$i] ."$", $entry)){
print "<li><a href=/$address/$entry'>$entry</a>";
}
}
}
}
print "</ul>";
}
directory_tree("/pinoc/rsrc2/scripts");
?>
Here is the code for listing the directory - but would like to expand each directory only when clicked
Any help on this will be much aprreciated
Thanks
Biju
<?
function directory_tree($address){
$exts = array("vbs", "js");
$dir = opendir($address);
if(!$dir){
return 0;
}
print "<ul>\n";
while($entry = readdir($dir)){
if(is_dir("$address/$entry") && ($entry != ".." && $entry !="." && $entry !=='icons' && $entry !=='hidden')){
print "<li><a href='$_SERVER[PHP_SELF]?expand=$address/$entry'>$entry</a>\n";
directory_tree("$address/$entry");
}else{
for ($i = 0; $i < count($exts); $i++){
if (eregi("\.". $exts[$i] ."$", $entry)){
print "<li><a href=/$address/$entry'>$entry</a>";
}
}
}
}
print "</ul>";
}
directory_tree("/pinoc/rsrc2/scripts");
?>