Hi there:
I am creating a web page where in it list all the files/directories.
I would like to have the same functionality as a windows file explorer. expanding the directory when clicked
Can somebody help me out on this
Thanks
Biju
Here is the code
$root = "/pinoc/scripts/";
print (" <td><table border=0>");
if ($GET[expand]) {
$expanded =explode ('/',trim($GET[expand],"/"));
$level = count($expanded)-3;
//print $expanded[3];
coldata($_GET[expand],$level);
}else{
coldata($root,0);
}
function coldata($in_dir,$in_level)
{
// print $expanded[$in_level-3] . $in_level;
$exts = array("vbs", "js");
if (is_dir($in_dir)) {
if ($dh = opendir($in_dir)) {
while (($file = readdir($dh)) !== false){
if ($file !== '.' && $file !== '..' && $file !=='icons' && $file !=='hidden') {
if (is_dir($in_dir ."/". $file)){
$dirs[]=$file;
}else{
for ($i = 0; $i < count($exts); $i++){
if (eregi(".". $exts[$i] ."$", $file)){
$files[] = $file;
}
}
}
}
}
}
closedir($dh);
}
sort($dirs);
$test = explode('/pinoc/rsrc2/scripts',$in_dir);
$test1 = explode ('/',$test[1]);
print ("<tr><td>$test1[1]</td></tr>");
for ($j=1;$j<count($test1);$j++){
print ("<tr><td> </td><td>$tempval</td></tr>");
}
foreach($dirs as $value){
print "<tr><td><a href='$_SERVER[PHP_SELF]?expand=$in_dir$value/'>$value</a><td></tr>\n";
// print "<tr><td>$value</td><td>$expanded[$in_level]</td></tr>";
if ($value == $expanded[$in_level+1]){
print "<tr>test</tr>";
}
}
//print count($files);
if (count($files) > 0){
foreach ($files as $file){
print "<tr><td>$file</td></tr>";
}
}
}
?>