[英]Firefox not setting the right content-type for multipart request
Given the following javascript code (a simple upload script): 给出以下javascript代码(一个简单的上传脚本):
var fd = new FormData();
fd.append("file", document.getElementById('file').files[0]);
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", 'http://localhost:22977/home/upload');
xhr.send(fd);
IE 10
and Chrome 28.xxx
will send the post request with the Content-Type
set as multipart/form-data
. IE 10
和Chrome 28.xxx
将发送post请求, Content-Type
设置为multipart/form-data
。 However Firefox 21
will set it as application/json
. 但是Firefox 21
会将其设置为application/json
。
Setting the Content-Type
by: 通过以下方式设置Content-Type
:
xhr.setRequestHeader("Content-Type", "multipart/form-data");
Still doesn't affect the Content-Type
when Firefox
is making the request. 当Firefox
发出请求时,仍然不会影响Content-Type
。
How can I make Firefox
use the right Content-Type
? 如何让Firefox
使用正确的 Content-Type
?
EDIT 编辑
IE 10
and Chrome 28.xxx
request headers: IE 10
和Chrome 28.xxx
请求标头:
Firefox 21
request headers: Firefox 21
请求标头:
I use Firefox to send MPE requests via FormData regularly, and was doing so without issue in 21 for some time. 我使用Firefox定期通过FormData发送MPE请求,并且在21年内没有问题这样做了一段时间。 It has to be some plugin you have installed, I would think. 我想,它必须是你安装的一些插件。 Disable all Firefox extensions and try again. 禁用所有Firefox扩展,然后重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.