saving an image object in sql server database from action method
- by user3532152
[HttpPost]
public void Test(HttpPostedFileBase file)
{
UsersContext db = new UsersContext();
byte[] image = new byte[file.ContentLength];
file.InputStream.Read(image, 0, image.Length);
CrimeReport i = new CrimeReport
{
ImageId=1, ImageName="Anjli",ImageContent = image,
Active=true
};
db.CrimeReports.Add(i);
db.SaveChanges();
}
I am getting an exception on db.CrimeReports.Add(i);