帮我看看吧,实在看不出来那错?
我仿照一篇文章坐了一个图片上传到SQL Server然后显示的例子
数据库中已经可以看见记录了
可是图片老是显示为一堆乱码,浏览器不能识别,让我下载
是存时的错,还是读时的错?
请赐教!
'***********Saveimage.asp**********************
response.buffer=true
totalsize=request.totalbytes
imagedata=request.binaryread(totalsize)
bncrlf=chrB(13)&chrB(10)
divider=leftB(imagedata,clng(instrB(imagedata,bncrlf))-1)
datastart=instrB(imagedata,bncrlf&bncrlf)+4
dataend=instrB(datastart+1,imagedata,divider)-datastart
mydata=midB(imagedata,datastart,dataend)
%>
<!--#include file="adocon.asp" --> '数据库连接设置
<%set rst=Server.CreateObject("ADODB.Recordset")
rst.open "Select * from images where 1<>1",conn,1,3
rst.addnew
rst("image").appendchunk mydata&chrB(0)
rst.update
rst.close
conn.close
set rst=nothing
set conn=nothing
%>
‘********************Viewimg.asp******************
<!--#include file="adocon.asp" -->
<%
id=Request.QueryString("id")
if id="" then id="1"
id=cint(id)
set rst=Server.CreateObject("ADODB.Recordset")
rst.open "select * from images",conn,1,3
while not rst.EOF
imgid=cint(rst(0))
Response.Write "<a href=""viewimg.asp?id="& imgid & """>" & imgid & "</a>"
rst.movenext
wend
rst.Close
sqlstring="select * from images where id="&id
rst.open sqlstring,conn,1,1
if not rst.EOF then
Response.ContentType = "image/*"
imgsize=rst("image").actualsize
Response.BinaryWrite rst("image").getChunk(imgsize)
else
response.write "图片已经被删除!"
end if
rst.close
conn.close
set rst=nothing
set conn=nothing
%>