Bug 19901
Summary: | XMLHttpRequest Async Request onreadystate does not go past 1 when uploading a file | ||
---|---|---|---|
Product: | WebKit | Reporter: | Shiv Kumar <shivk> |
Component: | XML | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | ap, emacemac7, shivk |
Priority: | P2 | ||
Version: | 525.x (Safari 3.1) | ||
Hardware: | All | ||
OS: | All |
Shiv Kumar
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.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
Do you have an example of this problem? It's not clear what you mean by file upload - is it form submission?
Shiv Kumar
(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.
Alexey Proskuryakov
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 ***