Welcome to WebmasterWorld Guest from 54.196.246.145

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

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

Junior Member

5+ Year Member

joined:July 28, 2006
posts:168
votes: 0


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

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

Senior Member

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

joined:Nov 12, 2005
posts:5966
votes: 0


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.
9:54 pm on June 7, 2007 (gmt 0)

Junior Member

5+ Year Member

joined:July 28, 2006
posts: 168
votes: 0


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

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

Senior Member

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

joined:Nov 12, 2005
posts:5966
votes: 0


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.

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

Administrator

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

joined:July 31, 2003
posts:12537
votes: 0


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.
11:44 pm on June 7, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts:489
votes: 0


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.

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

Administrator

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

joined:July 31, 2003
posts:12537
votes: 0


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members