I would like to upload an image from an asp.NET Web Forms (4.0) application to an Oracle 11g database. Eventually, I would also need to retrieve the image.
I was told to use a blob type, but this can change if a better solution is found.
From the front end perspective I am using the asp.NET File Upload component and is great to select the path of the file.
What is the best way around it? Work with blob’s? work with bfile’s? upload the image on the server and just store the path?
Assuming you have a table called IMAGES with a BLOB column, you’ll want to do something similar to:
Update:
When it comes to display the image, you mainly need to understand that the HTML page only contains a reference to the image (
<img src="ImageFromDatabase.ashx?id=1234">) and that the image itself is served by a separate request. The following example uses a Generic Handler:I’ve omitted all the error handling which you should be added in a real application.
Update 2:
If you have a grid view, you could define the image column like this: