3

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.