1

I have an MVC Application that uses Entity Framework to comunicate with database.

I want to get an image that is saved in the DB and load it on screen, but I can't figure out the way to do this.

Thanks in advance.

Pedro

1

1 Answer 1

1

You probably save the image in the database with a byte array, then you must use System.Drawing.Image class to convert the byte array that came from the DB.

Consider "imageFromDb" as the array from the database.

using (System.Drawing.Image image = System.Drawing.Image.FromStream(new MemoryStream(imageFromDb)))

{
  // Do the job that you want with the image.
}

Wish you Luck :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.