upload with jqueryform and mvc
I'm trying to upload an image file using ajaxForm(). Somehow the server never gets the request. here's some code:
$('form').ajaxForm({
iframe: true,
type: "POST",
dataType: "json",
url: '/UploadPictureId',
data: {
academicPhotoId: $('#AcademicPhotoId')
},
success: function (result) {
alert("win");
}
});
and here's the method code:
开发者_StackOverflow社区 [HttpPost]
public JsonResult UploadPictureId(HttpPostedFileBase AcademicPhotoId)
{
return Json(...);
}
A few things to check:
- See my comment about making sure it's pointing to the correct URL in the first place.
- Your form should have enctype="multipart/form-data" on it.
- You may also have to set the response type to text/html as noted here
精彩评论