Closed tanordheim closed 9 years ago
Moving the code below the xhr.open
solves the error for me:
xhr.open('POST', settings.uploadUrl);
// Add any available extra headers
if (typeof settings.extraHeaders === "object") {
for (var header in settings.extraHeaders) {
if (settings.extraHeaders.hasOwnProperty(header)) {
xhr.setRequestHeader(header, settings.extraHeaders[header]);
}
}
}
xhr.onload = function() {
// If HTTP status is OK or Created
if (xhr.status === 200 || xhr.status === 201) {
me.onFileUploadResponse(xhr);
} else {
me.onFileUploadError(xhr);
}
};
if (settings.beforeFileUpload(xhr) !== false) {
xhr.send(formData);
}
return xhr;
Could you try it and check if it works for you as well? Tested in Chrome Version 40.0.2214.91 (64-bit) on Ubuntu
after providing extra headers, immediately after the image uploaded, the browser would redirect to the local path to the dropped image (default event it seems).
Moving the extra headers block below xhr.open
as suggested above worked perfectly.
@tamagokun thanks for the confirmation, i will make a fix soonish
Fixed in #54
In issue #46 support for extraHeaders was added; I attempted to use this now by adding the following to my InlineAttachment configuration:
Whenever InlineAttachment attempts to upload files now, I get this error:
I tried moving the block that sets the headers down until after the XMLHttpRequest has been opened, but this did strangely enough not seem to have any effect; the error still occured. I'm not familiar with this code, or really XMLHttpRequest in general, so I'm not quite sure what is going on here. I'd be happy to fix and submit a pull request, but some ideas about what might be going on here would be great.