I have wanted to write a program myself for a long time, but since Lai didn’t want to write about me, I happened to be free today, so I wrote this small program that is easy to understand at a glance. Without further ado, let’s start:
Let’s make an upload of. The field in the database is automatically numbered big, and the field type is OLE. Haha, just use the simple field uppic.asp upload program name <%
dimrs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes 'Get the size sent by the client formdata=request.binaryread(formsize)'Convert the data sent by the client into binary production bncrlf=chrB(13) & 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)'The above is the binary data of the image.
'www.knowsky.com
%>
<!--#include file="conn.asp"-->
<%
sql="select * from pic order by id desc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,2
rs.addnew
rs("big").appendchunk mydata 'Add to database rs.update
set rs=nothing
set conn=nothing
%>
The next step is to display the image display.asp
<!--#include file="conn.asp"--> 'Everyone knows this, it is a program connected to the database<%
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" 'You can also use the format of displaying pictures'Response.ContentType = "image/gif" to display in gif'Response.ContentType = "image/jpg" to display in jpg Response.BinaryWrite rs("big ") 'Display pictures rs.close
set rs=nothing
set connGraph=nothing
%>