为何不能显示图片????帮我看看(在线等)asp+access

biglrj99 2003-10-17 12:53:18
用前面这个文件显示就是显示不了,直接键入
showimg.asp?id=3
会提示下载文件showimg.asp,下了之后就是一堆二进制乱码

.....
<IMG SRC="showimg.asp?id=3" alt="无图片">
....

showimg.asp
<%
dim udb
udb="/db/db.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
myconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&udb&"")
Conn.Open MyConn

set rst=server.createobject("ADODB.recordset")
sql="select image from smallctg where id="&trim(request("id"))
rst.open sql,conn,1,1
if not isempty(rst("image")) then
Response.ContentType = "image/*"
size=rst("image").ActualSize
Response.BinaryWrite rst("image").getChunk(size)
rst.close
set rst=nothing
set conn=nothing
else
response.write("无此图片!")
rst.close
set rst=nothing
set conn=nothing
end if
%>
...全文
34 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxxstarii 2003-10-17
  • 打赏
  • 举报
回复
if not isempty(rec("image")) then

else
response.write"<br>"
response.write"<strong><font color=#FF0000>暂无图片!</font></strong>"
response.write"<br>"
rec.close
conn.close
set rec=nothing
set conn=nothing
end if

这些不要,刚测试了一下。。。
lxxstarii 2003-10-17
  • 打赏
  • 举报
回复
<%
set rec=server.createobject("ADODB.recordset")
sql="select image from smallctg where id="&trim(request("id"))
rec.open sql,conn,3,3
if not isempty(rec("image")) then
Response.ContentType="image/*"
Response.BinaryWrite rec("photo1").getChunk(7500000)
rec.close
conn.close
set rec=nothing
set conn=nothing
else
response.write"<br>"
response.write"<strong><font color=#FF0000>暂无图片!</font></strong>"
response.write"<br>"
rec.close
conn.close
set rec=nothing
set conn=nothing
end if
%>
水母在发光 2003-10-17
  • 打赏
  • 举报
回复
<%
set rec=server.createobject("ADODB.recordset")
strsql="select 图片字段 from 数据库 where id="&trim(request("id"))
rec.open strsql,cn,1,1


Response.ContentType = "image/*"

Response.BinaryWrite rec("图片字段").getChunk(7500000)


rec.close
set rec=nothing
set cn=nothing
%>
biglrj99 2003-10-17
  • 打赏
  • 举报
回复
试了也不行啊,依然如故~~~~~~~郁闷
lxxstarii 2003-10-17
  • 打赏
  • 举报
回复
sql="select image from smallctg where id="&trim(request("id"))

不能用request("id") 要先把“id”保存到session

用session(“id”)就可以了
lxxstarii 2003-10-17
  • 打赏
  • 举报
回复
<div align="center"><a href="show.asp?userid=<% =session("userid") %>" class="pt1"><font color="#0000FF">查看图片</font>

show.asp:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img src="showimg.asp">
</body>
</html>

这样就可以显示图片了
lxxstarii 2003-10-17
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<img src="showimg.asp">
</body>
</html>
biglrj99 2003-10-17
  • 打赏
  • 举报
回复
自己顶
biglrj99 2003-10-17
  • 打赏
  • 举报
回复
angelheavens(龙辉)
stefli(爱毅)
两位的方法都试过了还是不行页面只显示一个空的图片框,里面一个红叉~~~~~~~~~:<
stefli 2003-10-17
  • 打赏
  • 举报
回复
直接输入这个肯定是显示不了的,因为他是img的src属性
只有<img src="showimg.asp?id=3">才能显示。

判断用isnull
if not isnull(rs("image")) then
response.ContentType="image/*"
response.BinaryWrite rs("image")
end if
angelheavens 2003-10-17
  • 打赏
  • 举报
回复
把size=rst("image").ActualSize
Response.BinaryWrite rst("image").getChunk(size)改成:

Response.BinaryWrite rst("image").getChunk(7500000)试试

28,390

社区成员

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

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