I assume that you only mention the Stringbuilder and CSV file because that refers to your previous experiences with enabling file downloads to users.
It is a little bit unclear whether you want to receive the image file from the user or provide the image file for the user to download? I have therefore provided the solution to both questions.
How do you return an image from SQL Server with the httpResponse?
- Get the image data from the database
- Set the correct
content-type
of the response (e.g. image/jpg
, image/gif
or image/png
)
- Write the bytes of your image to the raw response stream
Here is a relevant thread with some code samples: How to load an image in ASP.NET from a database as a file in a web browser?
As specified in the preferred answer you should consider implementing an httpHandler to provide the images rather than serving them throug an ASPX-page (which is intended for html)
How do you enable image file upload to a SQL server database?
If you want to save an image file received from a file input control
into a database then you should check out this link:
How do you store a picture in an image column?