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?
Flex Multipart Upload Progress
Asked Answered
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.
this is exactly what I did. The problem is still that the event is only fired at the very end of the upload. –
Huston
perhaps your files are very small? Try with a bigger one. –
Omnidirectional
ive been trying with a file size of 1.6 MB, it takes about 20 secs to complete. –
Huston
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) –
Omnidirectional
im on 3.5sdk. The key difference is the use of multipart. If it was not multipart then your code would work fine. –
Huston
and why do you need it to be multipart? –
Omnidirectional
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 –
Cheston
© 2022 - 2024 — McMap. All rights reserved.