Read and Write images through ASP. NET and databases

Source: Internet
Author: User

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.