tags:

views:

238

answers:

5

I want to browse all folders on my computer without using opendir(), in PHP.

A: 

The result will be a very ugly combination of glob() and stat(). Is there some reason you can't work with opendir() and friends?

Edit:

If PHP does not have suitable permissions to access everything you want to see, using another function is not going to help.

What (exactly) are you trying to do?

Tim Post
well it restricts me to a single path and everything below, and why friends, didnt get that bit
So if the single path is the root directory, what's the issue? When I said 'and friends', I meant readdir, rewinddir, ...
Tim Post
Does PHP not have suitable permissions to access all of the directories that you want to see / manipulate? What OS are you using?
Tim Post
development in windows, production is Linuxlet me just rephrase my awkwardly phrased one. i want a directory display as java, which i know is not possible with php, therefore have to get it done programmatically.
+1  A: 

Why wouldn't you want to use the function that's actually provided to do what you want?

Julian Aubourg
well it restricts me to a single path and everything below
just start at the root and make a recursive function then. See: http://fr.php.net/manual/fr/function.opendir.php#85715
Julian Aubourg
A: 

Why don't you use the following?

opendir(DIRECTORY_SEPARATOR);
soulmerge
the idea is something like the photo upload of facebook
So you want to list the filesystem of the user? That's not possible with PHP.
Ward Werbrouck
I don't know anything on facebook but I don't think they are allowing others to see all folders on the server. Or do you mean you want the user of your site to upload something?
soulmerge
i want the user to select couple of files and upload rather than having multiple upload boxes.why are people downvoting this question?
Because you stated it incorrectly. Try editing your question adding this latest comment of yours.
Seb
+3  A: 

I think I managed to extract the real question out of the comments: What you actually want is to provide an upload of multiple files.

Answer: No this is not possible with PHP, since it is executed by the server, not by the browser. PHP can give you folders on the server, not on the machine of the user. If you want to upload multiple files in a single step, you should use flash, javascript or something similar.

soulmerge
+1  A: 

In one of the comments, seeming says:

i want the user to select couple of files and upload rather than having multiple upload boxes. why are people downvoting this question?

Well, it is because your question is unclear and it is impossible to answer without the context of multiple file uploads.

The answer is: you can't do that with PHP. PHP runs serverside, so it can only give you a list of all the folders on the server; not the folders on the client side.

So the solution you need will either be

  • a Java-Applet (Facebook uses this for multiple file uploads)
  • or Flash/Flex (Gmail multiple file upload)
Ward Werbrouck