How to upload a folder
Moderator: General Moderators
How to upload a folder
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...
Or, if I want use a HTML INPUT FILE FORM, can I make the "Open file dialog" can accept folder?
Thanks men...
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
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
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
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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.
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.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
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
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
Can't find it, do you know exact site?Kieran Huggins wrote:Google "flash folder upload" or something similar
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).
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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.