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.
Use FileReference.upload, that's specifically what that method is for, and you will have your progress indicator.
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 useURLStream
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.