Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queuing asynchronous HTTP file uploads

Is there a way to queue file uploads without resorting to Flash or Silverlight, just with cleverly used forms and JavaScript? Note that the upload should be executed asynchronously.

By "queuing" uploads I mean that if the user tries to upload multiple files, they should not be transferred simultaneously, but rather one at a time, in a single HTTP connection.

like image 498
dpq Avatar asked Feb 27 '10 19:02

dpq


1 Answers

I don't believe it's possible to do this on a single HTTP connection, due to limitations of the spec. However, you may get almost the same behaviour by placing the <input> fields in separate forms (be it with HTML or JavaScript) and submitting them in order.

Place their targets on an <iframe> and use the iframe.onload event to trigger the next form in the list.

Additional notes:

  • See this for reference targeting iframes. Note that this feature is unsupported in HTML/XHTML Strict.
  • The form.target attribute must be equal to the iframe.name attribute. iframe.id will not work; It causes a pop-up window in IE6 and FF3.5.
  • A working example of 'all at once' uploading using targeting is available here. I've cleaned up this example a bit and used it. It works in IE6 as well as any first-class browser.
like image 65
Jesse Hallam Avatar answered Oct 06 '22 02:10

Jesse Hallam