MVC 4 using JQuery Mobile - cannot upload file using post

允我心安 提交于 2019-12-23 05:23:43

问题


I'm trying to upload a file to MVC 4 Internet Mobile Project (from the template..) anyway, the code works fine until i add the JQuery Mobile library to the page and the file is passed null to the controller.

[HttpPost]
public ActionResult FileUpload(HttpPostedFileBase file)  
                                        --> file is null when using JQuery Mobile

Can someone show an example for how to enable the post to receive files ?

EDIT: from another check i did, it seems that when a file is picked from the file system, it comes out as null. checked it with javscript to see what happens when the file is changed.


回答1:


jQuery Mobile AJAXifies forms and as you already know it is not possible to upload files using AJAX. As a workaround you could add the data-ajax="false" attribute to your <form> element to prevent jQuery Mobile from hijacking it and using AJAX.



来源:https://stackoverflow.com/questions/12688514/mvc-4-using-jquery-mobile-cannot-upload-file-using-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!