1
我正在使用插件通過Ajax上傳圖像。這個插件的js源代碼是here。請求標頭在IE中不可用
如果你看到從1200起線,你注意到這一點:
// build query string
params = params || {};
params['qqfile'] = name;
var queryString = qq.obj2url(params, this._options.action);
xhr.open("POST", queryString, true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
xhr.setRequestHeader("Content-Type", "application/octet-stream");
xhr.send(file);
所以基本上,上傳的文件名可以作爲qqfile
參數或頁眉VAR:X-File-Name
。這兩種方法在FF /鉻完美地工作與此ASP.NET MVC代碼:
public JsonResult AjaxUpload(String qqfile)
{
String fileName = System.Web.HttpContext.Current.Request.Headers["x-file-name"];
//rest of the code
}
但在IE中,沒有這些作品的?頭var爲空(在調試我清楚地看到,這個參數是未發送)和1qqfile
始終爲"System.Web.HttpPostedFileWrapper"
。
有誰知道如何解決這個問題?
ps:這個插件的演示是here。
幹得好先生:)認爲這將是一個頭痛。您的解決方案適用於我。唯一的事情是qqFile.FileName獲取我的完整路徑,所以我不得不拆分出實際的文件名。 –
哇...它的工作,thanx! –