public async Task<ActionResult> Create( Shop model, HttpPostedFileBase PhotoImage)
{
if (ModelState.IsValid)
{
byte[] imageData = null;
using (var binaryReader = new BinaryReader(PhotoImage.InputStream))
{
imageData = binaryReader.ReadBytes(PhotoImage.ContentLength);
}
model.Photo = imageData;
db.Shops.Add(model);
await db.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(model);
}
<input type="file" name="PhotoImage" />