繁体   English   中英

Firefox没有为多部分请求设置正确的内容类型

[英]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 10Chrome 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 10Chrome 28.xxx请求标头:

在此输入图像描述

Firefox 21请求标头:

在此输入图像描述

我使用Firefox定期通过FormData发送MPE请求,并且在21年内没有问题这样做了一段时间。 我想,它必须是你安装的一些插件。 禁用所有Firefox扩展,然后重试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM