Bug 19901 - XMLHttpRequest Async Request onreadystate does not go past 1 when uploading a file
Summary: XMLHttpRequest Async Request onreadystate does not go past 1 when uploading a...
Status: RESOLVED DUPLICATE of bug 23933
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-05 01:24 PDT by Shiv Kumar
Modified: 2009-04-02 01:47 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shiv Kumar 2008-07-05 01:24:38 PDT
When uploading a file using multipart/form-data enc type, firing an async xmlhttp request the onreadystate does not go beyond 1 (in a rage of 1-4). As a result no asyc xmlhttp requests can be made while a file upload is taking place (thus no progress information can be got from the server asynchronously.

Making an xmlhttp synchronous request works as excepted.

This works in all IE and Firefox versions that support AJAX.
Comment 1 Alexey Proskuryakov 2009-04-02 01:08:30 PDT
Do you have an example of this problem? It's not clear what you mean by file upload - is it form submission?
Comment 2 Shiv Kumar 2009-04-02 01:18:55 PDT
(In reply to comment #1)
> Do you have an example of this problem? It's not clear what you mean by file
> upload - is it form submission?

Uploading a file using a form with enc-type set to multipart/form-data. Don't know how else to explain this. I'm uploading a file.

So essentially, while I'm uploading a file (that is the file upload is in progress, I'm trying to make an asyc xmlHttp request. This does not work as expected (as explained previously). All this does work in other browsers. The synchronous version does work here as well but the async version does not work.
Comment 3 Alexey Proskuryakov 2009-04-02 01:47:53 PDT
Thanks! This is the same as bug 23933, which was filed later, but has somewhat more detail and a test case, so I'll mark this as a duplicate.

A workaround in your case is to use XMLHttpRequest file upload instead of form submission. This is not supported in any Safari release yet, but is supported in Safari 4 beta. Untested pseudo-code:

var fileInputElement = ...
var file = fileInputElement.files[0]; // multiple files in one input element are supported
var req = new XMLHttpRequest;
req.open(...);
req.send(file);

*** This bug has been marked as a duplicate of 23933 ***