以下是图片提交并存入access数据库的程序
<%@ Language=VbScript %>
<% '图片提交
dim rs,strsize,strdata,divider,bncrlf,datastart,dataend,mydata,str_sql
response.buffer=true
strsize=request.totalbytes
strdata=request.binaryread(strsize)
bncrlf=chrB(13) &
chrB(10)
divider=leftB(strdata,clng(instrb(strdata,bncrlf))-1)
datastart=instrb(strdata,bncrlf &
bncrlf)+4
dataend=instrb(datastart+1,strdata,divider)-datastart
mydata=midb(strdata,datastart,dataend)
if mydata<>"" then
'连接数据库,请自行编写
Set rs = server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenKeySet
rs.LockType =adLockOptimistic
str_sql="select * from sjk_db order by id desc"
rs.Open str_sql,cnn,,,adCmdtext
rs("pic").appendchunk mydata
rs.update
Set rs = Nothing
Cnn.close
Set Cnn = Nothing
end if
%>
以下是显示图片程序:showimg.asp
<%@ Language=VbScript %>
<% '图片显示程序:只显示数据库最后一条内容
dim strid,rs,str_sql
'Strid = Trim(Request.QueryString("id"))
'连接数据库,请自行编写
Set rs = server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenKeySet
str_sql="select pic from sjk_tb order by id desc"
'str_sql="select pic from sjk_tb where id="&strid
rs.Open str_sql,cnn,,,adCmdtext
response.contenttype = "image/*"
Response.BinaryWrite rs("pic").getChunk(7500000)
Set rs = Nothing
cnn.close
Set cnn = Nothing
%>
调用showimg.asp时请用<img src="showimg.asp"> 肯定可以用,我自己用在主页上!