问题
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