473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dirlisting & filemanaging

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
2 1222
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character...
1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.