public ActionResult GetImage(int photoId) { PhotoToDB photo = db.PhotosToDB.FirstOrDefault(p => p.PhotoId == photoId); if (photo != null) { return(File(photo.Image, photo.ImageMimeType)); } else { return(null); } }
public async Task <ActionResult> Create([Bind(Include = "Name")] PhotoToDB photo, HttpPostedFileBase upload) { if (ModelState.IsValid && upload != null) { photo.ImageMimeType = upload.ContentType; photo.Image = new byte[upload.ContentLength]; upload.InputStream.Read(photo.Image, 0, upload.ContentLength); db.PhotosToDB.Add(photo); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(photo)); }
public ActionResult Create() { var photo = new PhotoToDB(); return(View(photo)); }