ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Life >

Mini programs that upload pictures to the database.

Sunday on October 16th, 2005Life

ASP uploads the picture to Mini Program in the database.

I happen to have something to use. I've been looking for it for a long time, but it's all half of the program. Either it doesn't work or it has a lot of problems. After working for a long time, I got a complete and useful paste.

1. Set up a database, the field id type in the table pic is automatically numbered, and the field pic type OLE.

II. Database connection conn.asp

 & lt;%' database connectionDim connDim connstrOn error resume nextConnstr="DBQ="+server.mappath (& quot;pic.mdb") + & quot;;DefaultDir=;DRIVER= {Microsoft Access Driver (* .mdb)}; & quotSet conn=server.createobject & quot;ADODB.CONNECTION")Conn.open connstr% & gt

III. Select page: index.asp

 & lt;form name="form" method="post" action="up.asp" enctype="multipart/form-data">& lt;input name="xx" type="file">& lt;input type="submit" name="Submit" value=" submission & quot;>& lt;/form>

IV. Upload page: up.asp

 & lt;%Dim formsize,formdata,bncrlf,divider,datastart,dataend,mydataResponse.Buffer=TrueFormsize=request.totalbytes' gets the size sent by the clientFormdata=request.binaryread (formsize) 'converts the data sent into binary production.Bncrlf=chrB (13) & chrB (10)Divider=leftB (formdata,clng (instrb (formdata,bncrlf))-1)Datastart=instrb (formdata,bncrlf & bncrlf) + 4Dataend=instrb (datastart+1,formdata,divider)-datastartMydata=midb (formdata,datastart,dataend)'is a total of binary data obtained from the picture.% & gt& ltter.Mushroom include file="conn.asp"-->& lt;%set rs= Server.CreateObject & quot;adodb.recordset")Sql="select * from pic"Rs.open sql,conn,3,3Rs.addnewRs (& quot;pic") .appendchunk mydata'is added to the databaseRs.updateRs.closeSet rs=nothing% & gt

5. Check out the picture page: show.asp

 & Lt _ share includes file="conn.asp"-->& lt;%id=Trim (Request.QueryString (& quot;id"))If id="" then id=1Set rs= Server.CreateObject & quot;adodb.recordset")Sql="select * from pic where id in (& quot;&id&") & quotRs.open sql,conn,1,1Response.ContentType = & quot;text/html"Response.BinaryWrite rs & quot;pic")Rs.closeSet rs=nothing% & gt; 

Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/life/Mini-programs-that-upload-pictures-to-the-database.htm