I am uploading a file to a server using a multipart URLLoader
. I am able to upload the file fine. I have tried to listen to the progress event on the URLLoader but it only fires at the very end of the upload. How do I get the progress event more consistently through the upload?
views:
78answers:
1
A:
Have a progress-bar:
<mx:ProgressBar width="100%" id="progBar" mode="manual" />
Register a progress event handler:
refUploadFile.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
And handle it:
private function onUploadProgress(event:ProgressEvent):void {
var numPerc:Number = Math.round(
(Number(event.bytesLoaded) / Number(event.bytesTotal)) * 100);
progBar.setProgress(numPerc, 100);
progBar.label = numPerc + "%";
progBar.validateNow();
}
If your files are small, it is normal to not receive many events. Try with bigger files.
Bozho
2010-09-21 05:28:15
this is exactly what I did. The problem is still that the event is only fired at the very end of the upload.
asawilliams
2010-09-21 15:22:28
perhaps your files are very small? Try with a bigger one.
Bozho
2010-09-21 15:26:18
ive been trying with a file size of 1.6 MB, it takes about 20 secs to complete.
asawilliams
2010-09-21 16:17:27
ok. what version of flex then? See, there is a lot of information unknown to me. (Btw, the above code works fine for me, so I'm surprised it doesn't for you)
Bozho
2010-09-21 16:30:31
im on 3.5sdk. The key difference is the use of multipart. If it was not multipart then your code would work fine.
asawilliams
2010-09-21 17:38:00
and why do you need it to be multipart?
Bozho
2010-09-21 18:01:38
UrlLoader fires ProgressEvent just for download operation, so itf fires the first event when all the file is uploaded and you are downloading the page. You can't use it to monitor upload
wezzy
2010-10-21 14:45:36