HttpPostedfileBase is null using jQuery Ajax

前端 未结 3 1828
萌比男神i
萌比男神i 2020-12-28 15:50

I have problem with uploading file In Asp.net Mvc. First of all I should use Ajax to pass the upload file value.

In javascript I have model that I fill it, When I c

3条回答
  •  感情败类
    2020-12-28 16:35

    View:

    
    

    View Model:

    public class PhotoAlbumViewModel {
        public  string Name { get; set; }
        public HttpPostedFileBase File { get; set; }
    }
    

    Controller:

    public JsonResult AddPhoto(PhotoAlbumViewModel model) {
        // var result =...
        // and set your result; 
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    

提交回复
热议问题