图片数据写入SQL

' 取得客户端送出的数据字节大小
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

 

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
 

你可能感兴趣的:(F),ASP)