public ActionResult ImageRetrieve(int imgID) { CONTRASTEntities db = new CONTRASTEntities(); var img = db.tb_r_travel_execution.SingleOrDefault(x => x.id_travel == imgID); return(View()); //add field "bytes" type data "Image" //return File(img.id_travel, "image/jpg"); }
public JsonResult ImageUpload(ImageViewModel model) { CONTRASTEntities db = new CONTRASTEntities(); int ImgId = 0; var Lat = "Latitude"; var Lon = "Longitude"; var file = model.ImageFile; byte[] Imagebyte = null; if (file != null) { //var fileName = Path.GetFileName(file.FileName); //var extention = Path.GetExtension(file.FileName); //var filenamewithoutextension = Path.GetFileNameWithoutExtension(file.FileName); file.SaveAs(Server.MapPath("/UploadImage/" + file.FileName)); BinaryReader reader = new BinaryReader(file.InputStream); Imagebyte = reader.ReadBytes(file.ContentLength); tb_r_travel_execution img = new tb_r_travel_execution(); //img.Lat = Lat; //img.Lon = Lon; img.desc_upload = file.FileName; //img.numbers = Imagebyte.ToString(); img.pic_path = "/UploadedImage/" + file.FileName; //img.IsDelete = 0; db.tb_r_travel_execution.Add(img); db.SaveChanges(); ImgId = img.id_travel; } return(Json(ImgId, JsonRequestBehavior.AllowGet)); }
// GET: TravelExecute public ActionResult Executed() { CONTRASTEntities db = new CONTRASTEntities(); return(View()); }