My Table in the Database contains a column with a type : image.
I have managed to upload the image to the database.
But almost all tutorials out there, shows us how to give the Image Controller a URL which contains the name of the page, plus a parameter that has the ID of the selected row in the Database
Example:
//Database codes here... (query..etc..)
SqlDataReader myReader = myCommand.ExecuteReader();
if (myReader.HasRows == true)
{
myReader.Read();
Response.ContentType = "image/jpg";
Response.BinaryWrite((byte[])myReader[0]);
Image1.ImageUrl="User.aspx?imgid=1";
}
So when I click on a specific button which should fetch this image from the database, then give that URL to the image, the image opens in full screen.. But I don’t want that, let’s say I have empty space in my page for an Image of 50px width and 50px height, how can I show the image inside this space? and keeping all the other contents? just like a user page, a profile page.
It’s usually far easier and less error-prone to store your images in the file-system and refer to your images in the database using the filenames of your images.
I’ve never come across a good reason to store images in a database.
Also, when you want to edit your image that’s stored in the database, then you are going to have to export it out of your database and then reimport it back in.