[英]Firefox not setting the right content-type for multipart request
给出以下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
和Chrome 28.xxx
将发送post请求, Content-Type
设置为multipart/form-data
。 但是Firefox 21
会将其设置为application/json
。
通过以下方式设置Content-Type
:
xhr.setRequestHeader("Content-Type", "multipart/form-data");
当Firefox
发出请求时,仍然不会影响Content-Type
。
如何让Firefox
使用正确的 Content-Type
?
编辑
IE 10
和Chrome 28.xxx
请求标头:
Firefox 21
请求标头:
我使用Firefox定期通过FormData发送MPE请求,并且在21年内没有问题这样做了一段时间。 我想,它必须是你安装的一些插件。 禁用所有Firefox扩展,然后重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.