<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客户端发过来的大小
formdata=request.binaryread(formsize)'把客户发过来的数据转成二进制作
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)'上面总共是取得图片的二进制数据
%>
< !--#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 '增加到数据库中
rs.update
set rs=nothing
set conn=nothing
%>
接下来是显示图片
display.asp
< !--#include file="conn.asp"-->
<%
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" '显示图片的格式也可以用
'Response.ContentType = "image/gif" 以gif显示
'Response.ContentType = "image/jpg" 以jpg显示
Response.BinaryWrite rs("big") '显示图片
rs.close
set rs=nothing
set connGraph=nothing
%>