I want to save images that are uploaded with httppostedfilebase into a database.
How do I do this? How do I structure the database fields? What code do I write to save it to the database?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, storing images in a database is a controversial subject, so make sure to consider whether this is really what you want. For an elaborate discussion see:
Storing Images in DB – Yea or Nay?
The next thing to consider is what technology to use. Will you be using Linq2SQL, NHibernate, Entity Framework or plain ADO.NET? When choosing technology you should take the overall application architecture into account and not just focus on storing images (unless that is all your app does). Once that is settled, check out how the chosen technology handles binary data.
You can get to the binary data through
HttpPostedFileBase.InputStream.