ASP.NET MVC 4 Web Api ajax file upload

后端 未结 2 1701
感情败类
感情败类 2020-12-16 03:30

I am developing some sort of service using asp.net mvc 4 web api. On one form user must upload few files and then submit form to server. Problem is in ajax file upload to as

相关标签:
2条回答
  • 2020-12-16 03:51

    You cannot upload files using pure javascript with AJAX in legacy browsers such as IE8. The reason for this is that you don't have access to the file contents that was selected by the user in a file input. And since you don't have access to this contents, you cannot send it to the server.

    You could use some of the existing file upload plugins:

    • Plupload
    • Blueimp
    • Valums Ajax Upload
    • Uploadify

    They will test the capabilities of the browser and if it supports HTML5 and the new XHR2 object which allows uuploading files with AJAX it will use that. Or if the browser doesn't support it, the plugin could fallback to either Flash or hidden iframes. So if you need to support legacy browsers you don't have much choice but either use some other client scripting technology such as Flash or use a hidden iframe which fakes the AJAX request and actually sends a normal multipart/form-data request.

    0 讨论(0)
  • 2020-12-16 04:11

    You could use silverlight drag'n'drop control for ie 7, 8 and 9

    0 讨论(0)
提交回复
热议问题