图片入库
<!–#include virtual=”/_inc/conn.inc”–>
<%
取得客户端送出的数据字节大小
frmsize=request.totalbytes
以二进制方式读取数据
frmdata=request.binaryread(frmsize)
去掉实际数据前、后的边界字符串行
bncrlf=chrb(13)&chrb(10)
divider=leftb(frmdata,clng(instrb(frmdata,bncrlf))-1)
datastart=instrb(frmdata,bncrlf&bncrlf)+4
dataend=instrb(datastart+1,frmdata,divider)-datastart
读出图象数据
mydata=midb(frmdata,datastart,dataend)
将图象数据存入数据库
strsql=”select * from tblimages”
set rs=server.createobject(“adodb.recordset”)
rs.open strsql,conn,1,3
rs.addnew
rs(“picdata”).appendchunk mydata
rs.update
counts=rs.recordcount+1
rs.close
conn.close
%>
读取图片
<!–#include virtual=”/_inc/conn.inc”–>
<%
sid=request.querystring(“id”)
strsql=”select picdata from tblimages where id=” & sid
set rs=server.createobject(“adodb.recordset”)
rs.open strsql,conn,1,1
response.contenttype=”image/*”
datasize=rs(0).actualsize
response.binarywrite rs(0).getchunk(datasize)
rs.close
conn.close
%>