Response.BinaryWrite 放到WEB页面的问题

pp_zy 2005-07-08 02:56:51
我有一个asp文件的内容如下
<%
id=trim(request("id"))
Set rst=Server.CreateObject("ADODB.Recordset")
sqlstr="select filevalue,fileContentType from infomation where number=" & trim(request("id"))
'sqlstr="select * from movie_commends"

' sqlstr= sqlstr & " where id='" &id& "'"

rst.Open sqlstr,Session("strconn"),3,1

'sql="select filevalue,fileContentType from senddate where id=" & trim(request("id"))

Response.ContentType = rst("fileContentType")
Response.BinaryWrite rst("filevalue").getChunk(7500000)
rst.close
set rst=nothing

%>
这样是可以正常显示数据库里面的内容的
可是我把这段代码加到页面里面就会出现乱码,而不能正确调出数据库里面的内容,代码如下:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
</head>

<body>
<%
id=trim(request("id"))
Set rst=Server.CreateObject("ADODB.Recordset")
sqlstr="select filevalue,fileContentType from infomation where number=" & trim(request("id"))
'sqlstr="select * from movie_commends"

' sqlstr= sqlstr & " where id='" &id& "'"

rst.Open sqlstr,Session("strconn"),3,1

'sql="select filevalue,fileContentType from senddate where id=" & trim(request("id"))

Response.ContentType = rst("fileContentType")
Response.BinaryWrite rst("filevalue").getChunk(7500000)
rst.close
set rst=nothing

%>
</body>

</html>
请哪位大虾能指点一下,加在页面里面就不能显示了,谢谢!
...全文
237 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
我不是面包 2005-07-08
  • 打赏
  • 举报
回复
Response.Buffer = True
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=temp.doc"
Response.CharSet = "UTF-8"
我不是面包 2005-07-08
  • 打赏
  • 举报
回复
Response.Buffer = True
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=temp.doc"
Response.CharSet = "UTF-8"
response.contenttype = "Application/msword"
response.BinaryWrite rs("wsnr").getchunk(7500000)
set rs=nothing
my_conn.close
一定要把response.clear
pp_zy 2005-07-08
  • 打赏
  • 举报
回复
哦,但是我所调出来的不全是图片类型,还有别的类型的东西啊,比如说WORD文档,EXCEL之类的
孟子E章 2005-07-08
  • 打赏
  • 举报
回复
你只能这样
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>
</head>

<body>
<img src="getImg.asp">

getImg.asp是最上面的代码

28,406

社区成员

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

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