簡體   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