Read and write image files to SQL Server database

Source: Internet
Author: User
server|sqlserver| Data | Database using ASP to read and write image files to SQL Server database

A form that sends an image file

Img_upload.asp



Second, accept the form from the image file

In the img_upfile.asp file


With the above code, the image file already exists in the variable MyData

Third, the image data into the database

The above code first to determine the database ID record in the field of newid has no data, if there is to update the database with the current data, if not the data inserted.

Please note: The NEWID is defined elsewhere, and the reader does not have to ignore

Read the image file in the database and display it on the Web page
Use the following code to display the data on the Web page, please note that the, label SRC indicates the showimg.asp file. That is, the tag does not necessarily point to. gif


The core part is in the showimg.asp file:


After you remove the data, output it to the browser with Response.BinaryWrite and GetChunk.


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.