图片入库
<!--#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
%>