To display image in your view
View
<form method="post" enctype="multipart/form-data">
@{
if (Model.Picture1 != null)
{
string imageBase64 = Convert.ToBase64String(Model.Picture1);
string imageSrc = string.Format("data:image/gif;base64,{0}", imageBase64);
<img src="@imageSrc" width="100" height="100" />
}
}
<input type="file" name="photo" id="files" accept="image/*;capture=camera">
<button type="button">Submit</button>
</form>
Controller
[HttpPost]
public ActionResult Edit(Accommodation accommodation)
{
if (Request.Files["files"] != null)
{
byte[] Image;
using (var binaryReader = new BinaryReader(Request.Files["files"].InputStream))
{
Image = binaryReader.ReadBytes(Request.Files["files"].ContentLength);
}
}
accommodation.Picture1=Image;
//your code to save data
}