Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

FileReference bytesLoaded - incorrect value?

Question posted by: cbellew (Newbie) on April 29th, 2008 02:07 PM
Hi guys, i wonder if anyone could help me with my problem.

Basically, i am creating a file upload tool in as3. I am using a FileReference object, calling browse() and then upload(). I have an event listener catching ProgressEvent.PROGRESS Events and using ProgressEvent.bytesLoaded to update a progress bar.

The bar works fine, but i only get expected results when the swf and receiving php script are both local. I.E. on my localhost. The bar increases steadily and completes. However, when i use the swf and script on my external testing server the bar will fill immediately and bytesLoaded will be equal to bytesTotal instantly - even if the file is a few MB!).

I assume this must be something to do with php??

Any help would be much appreciated!

Thanks

Chris

P.S. Code...

Code: ( text )
  1. var file:FileReference = new FileReference();
  2. file.addEventListener(Event.SELECT, selectHandler);
  3. file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
  4.  
  5. function selectHandler(e:Event)
  6. {
  7.     file.upload(new URLRequest("http://www.trancetutorials.com/testupload.php"), "image");
  8. }
  9.  
  10. function progressHandler(e:ProgressEvent):void
  11. {
  12.     progressBar.width = (e.bytesLoaded / (e.bytesTotal / 100)) * 3;
  13.     progressBox.text = (e.bytesLoaded / (e.bytesTotal / 100)) + "%";
  14. }
  15.  
  16. file.browse();
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Reply
Not the answer you were looking for? Post your question . . .
170,098 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Flash / Actionscript Forum Contributors