Upload | upload pictures | data | Database for a long time to write a program, but because Lai did not want to write me, today is just free, so write this small program is easy to see it, not much to say this start:
Let's do an upload. The field of the data base is automatically numbered with the ID big field type is OLE oh on the simple that field okay
uppic.asp Upload Program Name
<%
Dim rs
Dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
Formsize=request.totalbytes ' Gets the size of the client sent over
Formdata=request.binaryread (formsize) ' The data sent from the customer into binary production
BNCRLF=CHRB (+) & ChrB (10)
Divider=leftb (FORMDATA,CLNG (INSTRB (FORMDATA,BNCRLF))-1)
DATASTART=INSTRB (Formdata,bncrlf & Bncrlf) +4
DATAEND=INSTRB (Datastart+1,formdata,divider)-datastart
MYDATA=MIDB (formdata,datastart,dataend) ' above is to get the binary data of the picture
' Www.csdn.com.cn
%>
<!--#include file= "conn.asp"-->
<%
Sql= "SELECT * from pic-id DESC"
Set rs = Server.CreateObject ("ADODB.") Recordset ")
Rs. Open sql,conn,3,2
Rs.addnew
RS ("Big"). AppendChunk MyData ' added to the database
Rs.update
Set rs=nothing
Set conn=nothing
%>
Next is the display picture
Display.asp
<!--#include file= "conn.asp"--> "This is what everyone knows, he's a database-linked program.
<%
Id=request ("id")
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from pic where id=" & ID
Rs.Open sql,conn,1,1
Response.ContentType = "text/html" shows the format of the picture can also be used
' Response.ContentType = ' image/gif ' in GIF display
' Response.ContentType = ' image/jpg ' is shown in JPG
Response.BinaryWrite RS ("big") ' Show pictures
Rs.close
Set rs=nothing
Set conngraph=nothing
%>