Storing and retrieving images in sql server 2005 in asp.net via c#
How do I store and retrieve 开发者_开发百科images in sql server 2005 in asp.net with c#
You may store them as binary data. You may write a module (derived from IHttpModule), register it for RequestBegin event. When request come you may retrieve data from database, store it on disk with requested file name and this image will automatically be returned by built-in IIS handler (which is written in native code and works very fast).
Here is a project that does just the thing. All you need to do is move the storing and retrieving logic into your ASP .Net application.
It is not recommended.
Best practice is storing meta-data (here meta-data is you image file name) inside database and sotre them on file-system (for example c:\images). Then when you need an image you can ask database for its name and retreive it from file-system.
This helps you to have a compact database and maintenance became easy. Handling large databases backup/restore is a headache.
精彩评论