8
votes

I am developing image uploader in Flash. I use FileReference.browse to browse image then resize this image to 1000 x 1000 px, if the image is very big and then upload to server. I want to show progressbar for the image upload progress.

I am usinng URLLoader to send binary data of the resized images, but ProgressEvent on URLLoader doesn't work the way it is supposed to work. It is fired only after the image is completed uploaded instead of showing intermediate progress. ProgressEvent on FileReference works perfectly to show intermediate image upload progress.

Is there a way to display upload progress using URLLoader? or

Can we use FileReference to load modified image and then call FileReference.upload, that way it will be possible to show actual progress bar.


Update 1 :
But my problem is that I am resizing the browsed image after using FileReference.browse, and I want to upload resized images, not the original picture in FileReference object after browse. How do I use Filereference.upload in this case? Filereference.upload will upload original image not the resized one. Any idea, how to put the resized image into Filereference object and then use FileReference.upload.


Update 2 :
Not able to set data in dummy FileReference, data is read-only property.


Update 3 :
But this has same problem of not showing image upload progress, from the above link:

"Unfortunately there is a problem getting progress event. We cant show any progress during sending data to server because flash doesn't support it"

I am exactly looking for a solution for the above issue. URLLoader works fine to post the image data.

2
I'm doing the EXACT same thing and stumbled on the same problem. I'm thinking of putting a "imprecise loading bar" while the upload is in progress. - Danita
Given that in my case the resulting file usually has about the same size, I ended setting up a Timer with the estimated time the upload should take in most situations, and getting that timer to fire ProgressEvents for the progressbar to update. It's better than nothing and the users can't tell the difference. - Danita
Now thats what i call a 'brillant solution'. - Tom
It's clever but it's completely inaccurate. 'In most situations' doesn't mean anything. I'd rather use an indeterminate progress bar instead of lying to the user. - citizen conn

2 Answers

3
votes

URLLoader is setup in such a way that it CANNOT receive progress events until the load is complete, as noted HERE in the docs. You might be able to use URLStream instead to get the progress event as you desire perhaps? I'm not sure if the progress events for URLStream only fire for download of the server's reponse, or if they will fire for the full transaction (upload & download), the docs don't seem to specify precisely.

-1
votes

Use FileReference.upload, that's specifically what that method is for, and you will have your progress indicator.