我使用Valums Ajax上傳器。所有在Mozilla與此代碼的偉大工程:MVC Valums Ajax Uploader - IE不發送請求流.InputStream
查看:
var button = $('#fileUpload')[0];
var uploader = new qq.FileUploader({
element: button,
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
sizeLimit: 2147483647, // max size
action: '/Admin/Home/Upload',
multiple: false
});
控制器:
public ActionResult Upload(string qqfile)
{
var stream = Request.InputStream;
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
var path = Server.MapPath("~/App_Data");
var file = Path.Combine(path, qqfile);
File.WriteAllBytes(file, buffer);
// TODO: Return whatever the upload control expects as response
}
這是在這個崗位回答:
但問題是,這在IE中不起作用。我發現這一點,但我無法弄清楚如何實現它:
IE不 「request.InputStream」通過 HttpPostedFileBase從發送流...而不是讓 輸入流在 Request.Files []集合
此外,這在這裏顯示這個傢伙是怎麼做到的,但我不知道如何爲我的項目更改:
Valum file upload - Works in Chrome but not IE, Image img = Image.FromStream(Request.InputStream)
//This works with IE HttpPostedFileBase httpPostedFileBase = Request.Files[0]
as HttpPostedFileBase;
不能找出這一個。請幫忙! 謝謝
呀!你剛剛救了我一百萬小時 - 謝謝。 – 2012-02-01 13:36:37