Web Hosting Talk







View Full Version : PHP question


gcool12
05-07-2005, 02:18 AM
Is there any PHP script that allows users to upload entire folders instead of just files? My programmer said it was not possible I think it should be. Please help

gbulmash
05-07-2005, 03:11 AM
It's not possible because PHP is processed on the server side and the selection of files to upload is done on the client side. The average web browser will not let you select a folder to upload, just a file, and nothing you do in PHP can change that.

Now, you can create a form that lets you specify multiple files to upload. Perhaps you could create a client-side applet in Java or as an ActiveX module that recurses the user-selected directory, gets all the file names, then populates the form with them.

- Greg

TheSilverblade
05-07-2005, 11:55 AM
I don't think it's possible...
But if you have your ftp CHMOD correctly, you can let them upload in a folder which doesn't exist yet I think.

Cap'n Steve
05-08-2005, 02:37 AM
You might be able to do some sneaky things with ActiveX, but ordinarily you can't fill in the file input boxes automatically (it's a security issue). Anonymous FTP combined with a script to move the files is probably the only way to do it.

gbulmash
05-08-2005, 04:08 AM
Originally posted by Cap'n Steve
You might be able to do some sneaky things with ActiveX, but ordinarily you can't fill in the file input boxes automatically (it's a security issue). Anonymous FTP combined with a script to move the files is probably the only way to do it.

Sorry, but ActiveX and Java do let the user select multiple files for upload, or even let you select a folder to recurse. Security might prevent them from downloading files from your hard drive without your knowledge, but it doesn't prevent them from doing it if you help.

I knew I'd seen it done before, but didn't remember where. Now I do.

Shutterfly has an activeX control that allows you to drag-and-drop files, or navigate to a directory and select photos for upload (all or individually).

So I did a quick search on google (+"java" +"multiple file upload") and found results quickly. Selected Java because it doesn't limit you to IE users as ActiveX does. BadaBing, the first result is an open source applet called JUpload, which seems to do just what he wants, including allowing you to select a folder and recursively uploading the contents.

http://jupload.sourceforge.net/

If it's not to his taste, there were 3,520 results for that search. He can go with OSS or another type of "freeware", or he can pay for an applet. But they do exist... in droves.

- Greg

azizny
05-08-2005, 10:30 AM
Yes you can do it with PHP (with the help of Microsoft pubslihing wizard)..

Peace,

gcool12
05-09-2005, 03:32 AM
azizny, Can you be more specific?

mpeacock
05-09-2005, 11:49 AM
Why not upload a zip file and have your script unzip it on the server? No messing around with ActiveX, and it would be faster than uploading uncompressed files.

Cheers, Michael

Burhan
05-09-2005, 12:48 PM
Any applet that requires access to files that are NOT on the server that is run from requires security permissions (it needs to be signed).

So you will have to sign the applet with either a self-generated or bought SSL certifcate before it will work.

Nyture
05-09-2005, 03:01 PM
Its entirely possible, if not a bit complicated. If you know how addresses to folders on ur desktop work, then jsut create a form with a input box. Input that folder (full address).
Have a second box for where u want to upload on ur server (be it main site, or within another folder.) Then use a few is_file , is_directory and the like to store a list of the files & folders to an array (id make one for folders, and one for files.) Then go through and have it mkdir(); each directory in the directory array, and then go through and upload every image into their respective folder on the site... Complicated, but completely feasable ... Hell,Ive done it before, but it wasn't easy. Was an awsome script I did though. Wish I still had it.

If ya have any questions or need an help designing the script, Id be more than happy to offer some pointers and help. my email is nyture@hotmail.com