Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Uploading photos in a batch

Uploading a large number of photos in a directory all at once

     

ryan_b83

8:52 pm on Jun 7, 2007 (gmt 0)

5+ Year Member



Hello, I am trying to figure out a way to upload a large number of images all at once from within a local directory.

For example Facebook uses a Java applet which allows you to browse your local computer, choose images to upload, and all at once it will locally resize/optimize the file prior to uploading, then uploads all the pictuers selected all at once.

Now, I am not trying to compete with a solution that powerful, but I am looking to at least be able to upload more than one picture at once, rather than having to make 25 browse buttons.

Does anyone have any ideas? PHP preferred.

Thanks,
Ryan

eelixduppy

9:30 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



There seems to be a few classes that may help you along at phpclasses [google.com]. There are usually memory restrictions with php when dealing with multiple uploads that can be a pain to work around, if they can in the first place. Worst-case scenario is you allow only a few at a time.

ryan_b83

9:54 pm on Jun 7, 2007 (gmt 0)

5+ Year Member



Yea i looked on there. There are some solutions however they still require you to select one file at a time. Not very good for 100 images to upload at a time.

What does everyone think of this approach.

Have the user zip a file of images and upload that.

Server gets the file
Unzips it
Goes through all the files and one by one makes sure its a valid image
If it is then resize/move/rename the image, otherwise delete the file
then at the end delete the zip file...

Any thoughts?

Security issues?

Thanks,
Ryan

eelixduppy

9:57 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Sounds like a nice idea, however, php probably isn't going to be the best way to go through the images and resize them, etc... as it is likely to time out. Handle the upload with php and then I'm sure there are command line utilities you can use to resize the images and place them in the proper locations. A search might give you something...

>> security issues

You won't know what's in the folder until you unzip it, but you must make sure that the folder only contains image files. If it contains executables, etc, it could potentially be damaging.

coopster

11:37 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



The zip route seems most logical for an end user. Checking each image from a zip wouldn't be any different from checking each one individually. As eelix stated, you could either unzip and run through them via PHP during script execution or another option might be to queue them up and have a cron job process them every so often.

Nutter

11:44 pm on Jun 7, 2007 (gmt 0)

10+ Year Member



I have a program that goes the zip file route. Any jpg files in the zip are processed, any non-jpgs are ignored. And at the end of processing all the files are deleted so nothing nasty stays on the server. One thing you might do is allow jpgs and zips, that way if they only want to upload one or two files they can, but there's also an option to upload more.

The biggest thing you'll probably run into is server timeouts and limits on how big of a file you can upload to your server. I've had clients try to upload zip files that were in the several hundred meg range which obviously didn't work really well.

coopster

11:50 pm on Jun 7, 2007 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Two things you can do there for starters are use the set_time_limit() [php.net] function and also have a good analytical read of the PHP manual page on Handling file uploads [php.net], especially all the directives associated with uploads and the MAX_FILE_SIZE information.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month