I've been trying to get two sets of images uploaded. One a larger resized picture then a 100x100 thumbnail.
Is there any way to do this?
I tried simply calling the upload function twice which does not work just to see if I can copy two sets of files.
If anybody has a script similar to this it would be greatly appreciated.
March 9, 2010 - 11:50am
You must do this within the event loop:
1. Start the 1st resize upload
2. Handle progress, errors, uploadSuccess events
3. In uploadComplete requeue the file (see 2.5.0 docs)
4. In uploadComplete start the 2nd resize upload
5. Handle progress, errors, uploadSuccess events
6. In uploadComplete detect that we've uploaded both sizes
7. In uploadComplete start the next file (goto 1)
In our implementation we needed a variable (we kept it in customSettings) to track which size image we were on.
Only 1 upload can be in operation at a time. The purpose of the uploadComplete event is to notify you that the current upload is finished and you may begin another. This is why uploadComplete fires after uploadSucces AND after uploadError. uploadComplete doesn't care what happened to the upload it is just telling you that you can start another upload.
March 9, 2010 - 2:54pm
You are better off creating the other version on the server side if possible as you will only be uploading a single image if you do it that way.
Most of the server-side tools are much faster than the resample inside the flash control anyway. I do the same thing, upload a 1024x768 image and then create a 160x120 (or whatever) thumbnail with GDlib and PHP on the server side.
March 11, 2010 - 6:36am
I'm just trying to do the same thing with JSP ( client-side obviously ), and as a total newbee in Flash devs , i'm quite stuck...
Please let us know if you find the way to do this. I'll do so
March 11, 2010 - 6:45am
thanks for these information gyphie.
However it's still quite obscur to me. In your example can you verify that resized has been succesfull ?
How do you manage to POST the different resized images ? all at once or one by one ?
March 11, 2010 - 8:50pm
jmcknight
Do you have any sample code with your second resize done on the server side?
It might be easier just to have the uploader do the upload then handle all the resizing on the server side.
March 12, 2010 - 9:24am
the purpose of doing this on client side is not to load the servers with image processing which always costs a lot in terms of performance.
however it's true that it would be easier
March 16, 2010 - 4:43am
I notices that flash crashes when processing multiple resize from images to big size ( > 50 ko ).
Forcing garbage collecting before each resize helps but i don't have any idee of what's going wrong ... if any one does ...
March 16, 2010 - 9:27am
Have you tried the latest .swf file from the Google Code site? We've fixed a few issues and put up Beta3.2
http://code.google.com/p/swfupload/downloads/list
August 2, 2010 - 8:25am
I solved the problem with PHP
Add the next code in the file upload.php
move_uploaded_file($_FILES["Filedata"]["tmp_name"], "saved/" . $fileName); // this line is already in the script.
list($width, $height) = getimagesize("saved/" . $fileName);
$ratio = $height/$width;
if($ratio >= '1') // portret
{
$ht_tmb = 120;
$br_tmb = 120/$ratio;
}
else
{ // landscape
$ht_tmb = 120*$ratio;
$br_tmb = 120;
}
// create thumb
$source = imagecreatefromjpeg("saved/" . $fileName); // the just uploaded image
//--- resize uploaded file
$resize = imagecreatetruecolor($br_tmb, $ht_tmb);
imagecopyresized($resize, $source, 0, 0, 0, 0, $br_tmb, $ht_tmb, $width, $height);
imagejpeg($resize, "thumb/" . $fileName);
$image = imagecreatefromjpeg("thumb/" . $fileName);
imagejpeg($image, "thumb/" . $fileName);
// end of making thumb
Make a folder with the name "thumb" and chmod 777
Change in thumnail.php line 26 and 28, saved/ into thumb/.