Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to read image

Status
Not open for further replies.

Jefhandle

Technical User
Mar 9, 2005
69
DE
Hello,
1)I'm going to read an image from a MS SQL Server database
and get it back to the Browser as a image file.
I have no clue what the methode return value should be,a byte type?
Maybe in this way:
pulblic byte[] getImageThatShouldBeSaved(imgId)
{
return byte[]
}
??
2)As i said after return the image to the caller Method, user should be able to save image by klicking the
save button on the dialog page.
what is need to automaticly open the dialog window to save the image?

regards
 
Not exactly sure of how your site is set up or what exactly you are trying to accomplish, but its my experience that it works better (smaller SQL file = faster results) if you store a path in the sql database to the pictures. Then use code to take the path returned and display it on the page.
 
1) Suppose that you store all types of image, better return it as byte[].

2) You need to add 2 page headers: content-disposition = attachment, and content-type = application/download.
Thru the Response.OutputStream, clear the stream's contents, then write here the image data. If the image is too big, flush the image data in chunks.
 
i dont know if this approach is correct:
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("1-How to write myArray which is a byte[] type to in the
response object, because the myArray is not a file !!?
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
????????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top