Page 1 of 1

How to upload a folder

Posted: Mon Mar 26, 2007 9:49 am
by chakhar86
I need to upload a folder (with or without sub-folder) to a server folder.

Or, if I want use a HTML INPUT FILE FORM, can I make the "Open file dialog" can accept folder?

Thanks men...

Posted: Mon Mar 26, 2007 10:01 am
by Kieran Huggins
negative :-(

Best you could do is design some sort of flash or java applet that helped the user select multiple files

Posted: Mon Mar 26, 2007 5:59 pm
by chakhar86
I have this Idea..

first, create a folder in server with the same name of folder that user wants to upload.
next, read the content of the folder
next, depends on option wheter the user wants to upload the sub-folder, we can use recursive or just ignore the sub-folder (check the sub-folder with is_directory())
next, upload each file just like usual, use copy()
end of algorithm

Only the problem is, the user has to type the folder he/she wants to upload, I want to eliminate this not user-friendly method...

Please help me ASAP....

ps: I have write the code but I lost it, so I give u the algorithm

Posted: Mon Mar 26, 2007 6:02 pm
by chakhar86
Or, can we read the client computer folders?
If we can how you do that?

Posted: Mon Mar 26, 2007 6:08 pm
by John Cartwright
Both your suggestions are essentially the same thing. PHP is a server side language and is not aware of the client. To read the files from the client's computer you'll likely need to use a java applet.

The best PHP could do in this situation is have the user zip of their directory, and upload it to the server which will then decompress the file.

Posted: Mon Mar 26, 2007 6:35 pm
by chakhar86
How bout javascript?

And if its impossible, then where I should learn Java applet (are the clients must have JRE installed in their computer to read the applet?). I prefer Javascript then...

Posted: Mon Mar 26, 2007 6:47 pm
by Kieran Huggins
javascript's security layer will prevent what you want to do - you'll have to use either flash or a java applet. I'd recommend flash since you're already sort of familiar with javascript AND there's probably a tutorial / codebase out there already.

Google "flash folder upload" or something similar

Posted: Mon Mar 26, 2007 6:50 pm
by chakhar86
I got this Idea...

idea 1:
-use Javascript to read the folder in local disk
-user select the folder
-before submitting, there a java script that modify values of HTML input tag (I believe it can be done), this will make browser upload multiple (and I think PHP can accept multiple files upload)
-if the folder has sub-folder, maybe we can alter the name for tagging

idea 2:
-use Javascript to read the folder in local disk
-user select the folder
-Javascript zip the folder and toss it to HTML input tag
-submit it
-then let php unzip the folder

can those be done?

thanks

Posted: Mon Mar 26, 2007 6:56 pm
by chakhar86
Kieran Huggins wrote:Google "flash folder upload" or something similar
Can't find it, do you know exact site?
But I still prefer using javascript because the user won't have install anything in his/her computer (almost all browser support javascript right?). But if there is no other way, maybe flash is the best way (its lighter than JRE I think).

Posted: Mon Mar 26, 2007 7:30 pm
by John Cartwright
chakhar86 wrote:I got this Idea...

idea 1:
-use Javascript to read the folder in local disk

...

idea 2:
-use Javascript to read the folder in local disk

...
Both areas are impossible, as previously stated. Consider the security implications javascript could actually read the users harddrive..

Posted: Mon Mar 26, 2007 8:19 pm
by chakhar86
so, the last thing that can be done is using flash?
can u show me how?

Posted: Mon Mar 26, 2007 8:46 pm
by John Cartwright
I personally never bothered with flash, but I'm sure if you checked out http://www.hotscripts.com you'd probably come across something useful. To be honest, I didn't think flash was allowed permission to the client harddrive.. the only things I've come across are java applets.