ASP saves binary images to access database

Source: Internet
Author: User
This article is provided by topic.alibabacloud.com, which describes how to use ASP to upload binary images and save them to an Access database.

The specific implementation code is as follows:

Save Picture User upload page (3.asp):



Save Picture Page (2.asp):

<%response.buffer=trueformsize=request.totalbytesformdata=request.binaryread (formsize) Bncrlf=chrB () & ChrB (PIDER=LEFTB) (FORMDATA,CLNG (INSTRB (FORMDATA,BNCRLF))-1) datastart=instrb (Formdata,bncrlf & Bncrlf) + 4DATAEND=INSTRB (Datastart+1,formdata,pider)-datastartmydata=midb (formdata,datastart,dataend) Set connGraph= Server. CreateObject ("Adodb.connection") Conngraph.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\PHP\valve.mdb;" Set Rec=server.createobject ("Adodb.recordset") rec. Open "SELECT * from [user]", Conngraph,1,3rec.addnewrec ("img"). AppendChunk Mydatarec.updaterec.closeset rec= NothingSet conngraph=nothing%>




Picture Reading page (1.asp): This page does not allow HTML code, otherwise it will appear garbled!

<%set rs=server.createobject ("Adodb.recordset") sql= "" Rs.Open strsql,conngraph,1,1response.contenttype = "image/ * "Response.BinaryWrite RS (" "). GetChunk (8000000)%>

The number in GetChunk () must be greater than or equal to the number of picture bytes to display, otherwise the picture is not completely displayed!


Picture Display page (4.asp):


Article Address: http://www.php.cn/csharp-article-377483.html

Learn programming to topic.alibabacloud.com www.php.cn

~~~~

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.