public JsonResult <object> ProfilePicUpdate([FromBody] JObject json) { StudentVM re = JsonConvert.DeserializeObject <StudentVM>(json.ToString()); var obj = new object(); Dictionary <string, object> dic = new Dictionary <string, object>(); string Image1 = re.ProfilePic; string SavePath1 = ""; try { if (!string.IsNullOrWhiteSpace(Image1)) { var postedFile = Image1; if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/"))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Document/ProfilePic/")); } string ImagePath1 = HttpContext.Current.Server.MapPath("~/Document/ProfilePic/") + re.FirstName + re.LastName + ".jpg"; SavePath1 = "/Document/ProfilePic/" + re.FirstName + re.LastName + ".jpg"; if (File.Exists(ImagePath1)) { File.Delete(ImagePath1); } byte[] Image1D = Convert.FromBase64String(Image1.ToString()); Stream stmImage1D = new MemoryStream(Image1D); Bitmap originalBMP1 = new Bitmap(stmImage1D); originalBMP1.Save(ImagePath1); } using (StudentsEntities context = new StudentsEntities()) { var result = context.ProfilePicUpdate(re.StudentId, SavePath1); dic.Add("Status", "1"); dic.Add("Message", "Success"); } } catch (Exception E) { dic.Add("Message", E.Message); dic.Add("Status", "0"); } obj = dic; return(Json(obj)); }