开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜