A simple ASP. NET 2.0 example allows you to directly store images to the database through FTP, read the images from the database, and display them on the image control on the webpage. The. NET 2.0 API is used, so the example can also be applied in the ASP. NET 3.5 environment.
Writing environment: VS 2005, SQL Server 2005
Example download point:
Http://files.cnblogs.com/WizardWu/081118.zip
Figure 1 execution screen in this example
Advantages:
* Images can be directly stored in the database for convenient management. You can avoid duplicate image names and delete images when using Windows File Manager to manage images.ProgramDifficult to write and complicated to judge.
* After reading the image from the database, you can choose whether to directly display the image on a webpage or store a new file.
* The size of the image uploaded by the user can be limited in bytes ).
Disadvantages:
* The program is still defective. We recommend that you do not name the image files in Chinese. Although the Chinese image file can still be read and written normally, after reading it from the database, if you want to save a new file, the original Chinese file name will be lost and will be automatically converted to a Chinese-English-mixed non-Rule image file name.
* Image File Access consumes a large amount of hard disk I/O of the server and affects program performance. The larger the image size, the more obvious it is. When the image size exceeds 3 MB, you need to wait for 3 ~ 4 seconds.
Others:
Currently, only the varbinary (max) Type of SQL Server 2005 has been tested, and no other databases have been tested.