Reputation: 471
I'm using http://aquantum-demo.appspot.com/file-upload to upload files to my site.
The file uploads fine in Firefox and Chrome, but when I try to upload it from IE 9 the file parameter in Controller action is null. Any ideas ?
Thanks in advance.
Here is my Controller action:
[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() });
}
Here is my View:
<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>
And finally my jquery:
$('#upload_files').fileUpload({
url: '/Document/UploadFile',
method: 'POST',
uploadTable: $('#files'),
downloadTable: $('#files')
});
Upvotes: 3
Views: 2397
Reputation: 471
Had to add enctype = "multipart/form-data"
in my view form.
Now the file uploads fine, but after that the IE is trying to save the response.
So in the controller method I changed the content-type
to "text/plain"
and now
everything works ok.
Upvotes: 3