1

How can javascript know file upload progress? Is there some kind of standard communication method between the browser and the server that tracks progress and sends progress status back to the browser, or can it be done entirely from within javascript?

If it makes a difference I am using a JVM backend.

Thanks!

2
  • The new file API which is part of the HTML5 spec has been implemented in Firefox I think. This allows file uploading directly through javascript. But this is not supported in all browsers. The other option is to use AJAX and JVM to break up the file request as it comes in and save it in chunks, while your AJAX is requesting progress information. It also requires an iFrame. I can tell you now that (in C# at least) it's not easy to do. Commented Oct 12, 2011 at 23:23
  • And the other option again is to use a pre built component which while expensive, may actually save you money in developing costs. Commented Oct 12, 2011 at 23:24

2 Answers 2

2

There are lots of solutions for this. Generally, javascript on its own has no notion of bytes being transferred, so you need to use AJAX to get back the percentage of bytes transferred. Here's a tutorial for JSP. Other solutions use flash.

0

It's impossible. You can however do something like this

http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

4
  • It's not impossible, it's just not a beginners task. Many sites do it Gmail being an obvious example. Commented Oct 12, 2011 at 23:26
  • you're right nothing's impossible... it is computer after all Commented Oct 12, 2011 at 23:29
  • Philip Burch: I have that part. What I need now is some kind of feedback about file upload progress. This example just has a .gif spinning while the file uploads. Commented Oct 13, 2011 at 0:36
  • This is because by default, the target that you post the form to won't be called until the entire POST request has been received. That means the entire file. Therefore you need a way to intercept the POST request as soon as the first part comes in and save it manually. In ASP.Net you would use an HttpModule, I read here that Filters are the Java equivalent but I'm not too sure about that. Commented Oct 13, 2011 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.