ebb
ebb

Reputation: 9377

Firefox not setting the right content-type for multipart request

Given the following javascript code (a simple upload script):

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.x.x.x will send the post request with the Content-Type set as multipart/form-data. However Firefox 21 will set it as application/json.

Setting the Content-Type by:

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

Still doesn't affect the Content-Type when Firefox is making the request.

How can I make Firefox use the right Content-Type?

EDIT

IE 10 and Chrome 28.x.x.x request headers:

enter image description here

Firefox 21 request headers:

enter image description here

Upvotes: 0

Views: 1073

Answers (1)

Ray Nicholus
Ray Nicholus

Reputation: 19890

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.

Upvotes: 2

Related Questions