从数据库取图片,无法在页面上显示出来~~?

noahart 2004-01-06 01:12:03
取图片showimg.asp
<%
set connGraph=server.CreateObject("ADODB.connection")
connGraph.ConnectionString="driver={SQL Server};server=Localhost;database=FileTest;uid=sa;pwd="
connGraph.Open
set rs=server.createobject("ADODB.recordset")
strsql="select img from images where id=3"
rs.open strsql,connGraph,1,1
Response.ContentType = "image/gif"
Response.BinaryWrite rs("img")
rs.close
set rs=nothing
connGraph.Close
set connGraph=nothing
%>
数据库存的图片rs("img")没问题~,rs("img").GetChunk(len)我也试过了,不行~
显示的时候就只有一个“X”
...全文
61 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
minghui000 2004-01-07
  • 打赏
  • 举报
回复
学习
noahart 2004-01-06
  • 打赏
  • 举报
回复
我想应该不是下载时的问题
我上传时用的是无组件图片上传
发现截下来文件流的字节比实际图片的字节多了2个,有人遇到过吗?
yangsm 2004-01-06
  • 打赏
  • 举报
回复
用二楼的,先把ID传来看看,然后于用
id=request("id")
strsql="select img from images where id="&id
这样,但要保证你的图片已经存到数据库中了
500sea 2004-01-06
  • 打赏
  • 举报
回复
Response.ContentType ="image/gif"
angel2a 2004-01-06
  • 打赏
  • 举报
回复
up
睿睿爸爸 2004-01-06
  • 打赏
  • 举报
回复
<img width='500' src="showpic2.asp?pic_id=<%=pic_id%>">
上一个就是showpic2.asp
睿睿爸爸 2004-01-06
  • 打赏
  • 举报
回复
SetForDisplay Rs("photo_file"), Trim(Rs("photo_type"))
Function SetForDisplay(photofield, contentType)
contentType = LCase(Trim(contentType))
nFieldSize = photofield.ActualSize
bytes = photofield.GetChunk(nFieldSize)
Response.Clear
Response.ContentType = contentType
Response.BinaryWrite bytes
End Function

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧