日期:2013-10-06  浏览次数:20931 次

<%
response.buffer=true
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)

set conn=server.createobject("adodb.connection")
conn.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.mappath("images.mdb")
conn.open

set rs=server.createobject("adodb.recordset")
rs.open "select * from [images] where id is null",conn,1,3
rs.addnew
rs("img").appendchunk mydata
rs.update
rs.close
set rs=nothing
set conn=nothing
%>


“showimg.asp”文件代码如下:

<!--#include file ="Conn.asp"-->
<%
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

ID = trim(Request("id"))
Response.ContentType = "image/*"
set rs_img=Server.Createobject("ADODB.Recordset")
sql="select img from TImage where ID=" & id
rs_img.open sql,conn,1,1


img_size = rs_img("img").ActualSize
Response.BinaryWrite rs_img("img").getChunk(img_size)
rs_img.close
set rs_img=nothing
set conn=nothing
%>