Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I store images in database as byte array.I want to open the image in a page after clicking button.I have tried response.binarywrite() method keeping the page content type="image" but can not save that in jpg or jpeg format.so how to do in c#?
Posted

1 solution

Use the below code in the download picture page:
C#
string strFileName ="pic.jpg";
byte[] bytes = // get byes from the database table using your DB code/function
Response.Clear();
Response.AppendHeader("Content-Disposition", "filename=" + strFileName);
Response.AppendHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(bytes);
Response.End();
 
Share this answer
 
Comments
souvikcode 17-Aug-13 1:45am    
fine srinivas.very very helpful.Would you help me on another issue?After clicking the link many websites open the images in a new tab.How is it done in asp?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900