0

给定以下 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.x.x.x发送Content-Type设置为的 post 请求multipart/form-data。但是Firefox 21将其设置为application/json.

设置Content-Type方式:

xhr.setRequestHeader("Content-Type", "multipart/form-data");

仍然不影响Content-Type何时Firefox提出请求。

我怎样才能Firefox使用权利 Content-Type

编辑

IE 10Chrome 28.x.x.x请求标头:

在此处输入图像描述

Firefox 21请求标头:

在此处输入图像描述

4

1 回答 1

2

I use Firefox to send MPE requests via FormData regularly, and was doing so without issue in 21 for some time. It has to be some plugin you have installed, I would think. Disable all Firefox extensions and try again.

于 2013-07-05T12:46:58.060 回答