By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Dirlisting & filemanaging

P: n/a
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] =>
)
)
)
Jan 8 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Rob
On Jan 8, 8:01*pm, frizzle <phpfriz...@gmail.comwrote:
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] =>
* * * * )
* * )
)
For this particular task, I would using this piece of software :-

http://extplorer.sourceforge.net/

I'm sure it will probably do everything you need, including FTP
connections.

Rob.

BTW, I have no affiliation with the author - it's just a good piece of
software
Jan 9 '08 #2

P: n/a
On Jan 9, 10:50 am, Rob <ratkin...@tbs-ltd.co.ukwrote:
On Jan 8, 8:01 pm, frizzle <phpfriz...@gmail.comwrote:
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] =>
)
)
)

For this particular task, I would using this piece of software :-

http://extplorer.sourceforge.net/

I'm sure it will probably do everything you need, including FTP
connections.

Rob.

BTW, I have no affiliation with the author - it's just a good piece of
software
Thanks Rob for your tip, but i'm actually starting on building quite
the same thing myself, as a part of a bigger CMS.
That's why i was looking for the aforementioned. Nevertheless, i'll
have a look at your option.

Regards, Frizzle.
Jan 9 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.