MozillaZine

Tracking file upload with nsIProgressEventSink

Talk about add-ons and extension development.
stonedyak
 
Posts: 80
Joined: August 11th, 2003, 10:23 am
Location: UK

Post Posted March 1st, 2007, 3:27 pm

I'm writing an extension which needs to upload files to a web server. I have the file upload part working fine (I've based my JS code on http://lxr.mozilla.org/seamonkey/source ... on.cpp#593 ).

I'm using nsIProgressEventSink to track the file upload. When I upload a file, the 'progress' parameter passed to the onProgress listener goes from 0 up to the file size. However if I upload a second file straight away, the 'progress' parameter continues counting up from the file size of the previous upload (but the progressMax parameter is correct). If I wait a minute or so before uploading another file then the 'progress' parameter starts from 0 again.

I've based my progress listener code on this developer.mozilla.org article. I've put all the code into a single .js file that you can try it out using the 'Javascript Environment' from the Extension Developer Extension. Hopefully you'll see the same thing as I do.

I'd be really grateful if someone could take a look at the code and tell my why this is happening.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest