Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have a table that have 2 columns (ImageData of type varbinary(MAX) and id of type int).
i want to to read images from db and save them in the client's FileSystem.
i googled but it just for how to show them on the client's browser and i don't need it.
any idea how can i do that?
zip images on server and give link to client ??
Posted
Comments
Sergey Alexandrovich Kryukov 24-Sep-13 10:05am    
Good question which confuses many, rightfully formulated; I up-voted it.
—SA

1 solution

If you want to use ZIP and you think this would be fine for your users, it will certainly work. But you don't have to give a link to the file stored to on the server side. If you want, you can do it on the fly, using the class System.Net.HttpWebResponse with corresponding ContentType. Please see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx[^],
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx[^] (see the code sample here),
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.contenttype.aspx[^].

In case of ZIP, your content type should be "application/zip". For other types, please see:
http://en.wikipedia.org/wiki/Internet_media_type[^],
http://www.iana.org/assignments/media-types[^].

However, your content does not have to be ZIP. You can still use your particular image type, but enforce saving the image instead of rendering it on the page. For this purpose, you should add your own HTTP request header which can look like this:
Content-Disposition: attachment; filename="some-file-name"


There is no a special property for this particular header in the HttpWebRespose class, so you need to compose this header and add it using the property System.Net.HttpWebResponse.Headers:
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.headers.aspx[^].

—SA
 
Share this answer
 
Comments
Eduard Keilholz 24-Sep-13 10:18am    
Good answer +5
Sergey Alexandrovich Kryukov 24-Sep-13 10:23am    
Thank you, Eduard.
—SA
Reza Oruji 24-Sep-13 10:20am    
Thanks, what if in case that there are more than one Image ?
Sergey Alexandrovich Kryukov 24-Sep-13 10:24am    
In single-file save? Than, apparently, you can always ZIP them together. Why not?
I think I answered on all your options. Will you accept the answer formally now?
—SA
Reza Oruji 24-Sep-13 10:31am    
Thank you Sergey

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