2011-10-06 51 views
3

我正在使用http://aquantum-demo.appspot.com/file-upload將文件上傳到我的網站。Blueimp jquery-file-upload通過IE在MVC控制器中提交空文件9

該文件在Firefox和Chrome中正常上傳,但是當我嘗試從IE 9 上載時,Controller操作中的文件參數爲空。 任何想法?

在此先感謝。

這裏是我的控制器動作:

[HttpPost] 
public JsonResult UploadFile(HttpPostedFileBase file, FormCollection collection) 
{ 
    var model = newObject(); 
    TryUpdateModel(model);     
    model.ID = saveDocObject(model); 

    Guid fileid = saveUploadedFile(model.ID, file); 

    return Json(new { name = file.FileName, fid = fileid.ToString() }); 
} 

這是我的觀點:

<div id="upload_files"> 
     <div id = "filediv"> 
      <input type="file" name="file" class="green"/> 
      <button>Upload</button> 
     <div>Upload it</div> 
     </div> 
</div> 
<table id="files" width="200px"> 
</table> 

最後我的jquery:

$('#upload_files').fileUpload({ 
    url: '/Document/UploadFile', 
    method: 'POST', 
    uploadTable: $('#files'), 
    downloadTable: $('#files') 
}); 

回答

3

只好在我看來表單中添加enctype = "multipart/form-data"。 現在文件上傳正常,但之後,IE試圖保存響應。 因此,在控制器方法中,我將content-type更改爲"text/plain",現在 一切正常。

相關問題