SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple image uploading ... what's the best way .. thanks.

    Hi guys

    Well, I need users to upload their photos in one of my sites. Thing is that letting them upload photos one by one will be too hectic as there will be hundreds of photos per user, and I was thinking to let them upload photos in batch, say in a zipped file. Here is what I am thinking to do.

    Users
    Users will save all their photos in one folder and then zip it using something like winzip
    I will have to find a way so that users can upload that zip file to my server

    Me, then ...
    Once uploaded, unzip the file
    Will check if all the files carry a permitted extension, .jpg, .png, etc. (to get rid of viruses and bad extensions)
    If everything goes OK, will resize the image in two sizes, thumbnail and display (say, 450 px), by taking the photos from the folder
    Users will have an option to add more photos in the same folder

    I thought I will ask you guys what do you think about this solution. Any security problem, tips, ??? Or, you have a better solution. I use php. thanks.

  2. #2
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This might get you started:

    http://www.devarticles.com/c/a/PHP/C...Script-in-PHP/

    If your users need to upload lots of files, I think zipping them all first is the way to go. You can upload a zip file as easily as an image, then unzip it on your server.

    There is a script around that does this already ... I'll see if I can track it down.

    Mike

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created something like this a few years ago, I'll try and see if I can find it, but it accepted .tar.gz .zip, regular images, and even would pull images from external sites i.e. http://www.google.com/logo.png. Although yes, you can definately do this with php, look into zlib and compression for unziping the .zip / .tar files, also, I believe PEAR has a nice handy class now days for extraction, just some food for thought -- well good luck, and I will try and find my function...

  4. #4
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mike, thanks Tux, if you guys can find out the script you are speaking about, it will save me a lot of time ... thanks again.

  5. #5
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I have just checked Mike's page. This seems pretty similar to Mayank's one http://www.sitepoint.com/article/php...system-minutes. Hmm ... i think i need the zipping solution ...

  6. #6
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found it. I bought this script a while ago:

    http://www.scriptsnmore.com/

    My understanding is that it isn't suitable for use as-is because there are some security holes which have been fixed in the current yabsoft version.

    However, it does contain upload and unzipping functions that you could learn from.

    There is a thread at namepros where a guy is (legally) giving the script away:

    http://www.namepros.com/code/191933-...ng-script.html

    Mike

  7. #7
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot. It looks great. Just a question. Once I upload the zipped file, and unzip that thereafter, I will need to resize them to two different sizes, one for thumbnail and another prefixed size for displaying. Wondering, is that possible technically? I mean, taking images from a folder in the server and then resize them, save the resized versions in the same (or a different location), and delete the original bigger images ...

    thanks again.

  8. #8
    SitePoint Guru toasti's Avatar
    Join Date
    Feb 2004
    Location
    Grahamstown
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes. this is possible. I have a script which does exactly what you are wanting to do. it iterates through a directory on the server and copies resized and thumbnailed pictures to a new directory on the server.

    I have attaced a class for making thumbnails (its from the sitepoint php anthology book infact).

    usage is very simple:
    Code:
    $image = file_get_contents($fromDir."/".$img);
    $pic = new thumbnail(640,480);
    $pic->loadData($image, 'image/jpeg');
    $pic->buildThumb($toDir."/".$img);
    I like your idea of uploading a zip file.
    I have battled with the whole uploading a lot of pictures problem.
    some other solutions which i came up with to solve this problem are:
    :: ajax uploader (http://www.sitepoint.com/forums/show...ht=ajax+upload)
    -> its ok, but the person has to upload one picture at a time, and resizing is done on the server side.
    :: java application -> works well, resizing can be done client side thus reducing load and bandwidth, but getting users to install and run a Java app is ADMIN, cause i found most didnt have the JVM...so they have to install that...and well..most couldnt.
    :: java applet -> i have just finished this one, and it seems to be the best solution so far. a signed java applet has access to the filesystem. so you can do resizing client-side, and there is no install (except java plugin, which most borwsers have). have a look at thin slice upload (http://www.hotscripts.com/Detailed/53743.html) ...when i get round to it i want to release an open source applet uploader...but i cant gaurentee that will be tomorrow..or next week even!

    A major problem you might have with the uploading of a zip is that users will be uploading BIG files (if you are resizing server-side), and you may find these upload break over HTTP. also be sure to check out MAX_FILE_SIZE, cause this is set to 2mb by default.

    Good luck
    Attached Files Attached Files
    Last edited by toasti; Jul 18, 2006 at 05:44. Reason: forgot to attach the class!

  9. #9
    SitePoint Guru toasti's Avatar
    Join Date
    Feb 2004
    Location
    Grahamstown
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...hindsite...i am not sure what the liscense on Harry's Thumbnail class is!

  10. #10
    SitePoint Guru MikeBigg's Avatar
    Join Date
    Jun 2004
    Location
    Reading, UK
    Posts
    970
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IIRC, there is a multifile java applet in the scriptsnmore script I suggested ... I can't remember seeing the code, though.

    Mike

  11. #11
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys

    Well Mike, I downloaded that script and tried to open the applet in dreamweaver. I was unable as it was full of illigible characters ... I wish I could open that to see how that have been coded (though I am not a java guy) to make out something for my project ... toasti, you are right that I can't upload the zip to the server directly, as users will upload big files and 200 large files at one go if reaches the server, their resizing and all will crush my shared hosting.

    I indeed need a way to do everything client side, unzipping, opening up the folder, checking for unwanted file extensions, resizing to two different sizes, deleting the original bigger files and replace them with the new ones, and creating a new folder where the image files will be stored (or may be in the mysql, I don't know what would be the best way to store images in this case ...). And I understand that php being a server side language, won't be the best choice here. Have to go either for javascript or an applet, as once things are properly uploaded, rest of the things can be easily handled by php.

    Hmmm ...

  12. #12
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't even like the idea of using Zip files to be honest. It just is a pain for the user. It'd be nicer if you provided a drag and drop applet or something.
    ]

  13. #13
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, you do have a point here. Drag and drop to a client side application which will then do the backend job before uploading to the server sounds like a good solution. Or even better, if users can select their file and then click somewhere to do the transfer, as a lot of users don't even know how can they 'drag and drop' ...

    Ideas are there, but ... how to materialize

    All the solutions that I have got here are either with some limitations, or comes with a much larger pack like gallery, but what I need is just a way to upload the photos ... the rest of my site is already ready ...

  14. #14
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, may be I should get ready to pay someone to develop this applet ... outsourcing may be ... so long as the price remain reasonable and i get something good .. but I really thought that php could do everything ...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •