Blueimp Jquery-File-Upload通过IE 9在MVC Controller中提交空文件

时间:2011-10-06 14:19:30

标签: jquery asp.net-mvc asp.net-mvc-3

我正在使用http://aquantum-demo.appspot.com/file-upload将文件上传到我的网站。

文件在Firefox和Chrome上传很好,但是当我尝试从IE 9上传时 Controller操作中的file参数为null。 有什么想法吗?

提前致谢。

这是我的控制器操作:

[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')
});

1 个答案:

答案 0 :(得分:3)

必须在我的视图表单中添加enctype = "multipart/form-data"。 现在文件上传很好,但之后IE正在尝试保存响应。 因此,在控制器方法中,我将content-type更改为"text/plain" 一切正常。

相关问题