|
Posted by frizzle on 01/08/08 20:01
Hi there,
I'm buidling a php-app for online (ftp-based) file management. So far,
so good.
Now i've come to a point where i need to be able to copy / move
folders and files.
I have a function (below this post) that gives me an array of the
directory structure, luke the one below the message.
To jump to the problem:
I'd like to display the folders in a dropdown. What i'd like is to
have the following structure:
- scripts
- scripts / javascripts
- photos
- photos / black_white
- photos / black_white / sepia
- photos / illustrations
etc.
I'd like to convert the array below the message into the one above,
where each new line is a new array key.
After that, i need to be sure people don't move/copy folders to the
same folder in a higher level like copying "photos" to "photos /
black_white". How do i make sure current and all deeper levels are
disabled / removed from the list.
Thanks a lot!!
****** FUNCTION BELOW ******
function do_dirs($dir = '.', $loop = 0)
{
$handle = @opendir($dir);
while(($file=readdir($handle)) !== false ){
if($file != '.' && $file != '..'){
$point = $dir."/".$file;
if(is_dir($point)){
$info[$file] = do_dirs($point, $loop+1);
};
}
}
return $info;
}
print_r(do_dirs())
*** OUTPUT ***
Array
(
[scripts] => Array
(
[javascripts] =>
)
[images] => Array
(
[photos] => Array
(
[black_white] => Array
(
[sepia] =>
)
[color] =>
)
[illustrations] =>
[renderings] => Array
(
[3dmax] =>
)
)
)
[Back to original message]
|