asp下载数据库某一字段内容

漠叔 2009-09-03 08:33:36
比如表table中有一字段为content
现在要做一个下载功能,当用户点下载时把字段content中的内容做为一个txt文件提供给用户下载,应该如何做?
...全文
52 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhengmenghua 2009-09-04
  • 打赏
  • 举报
回复
测试了一下 提示错误 百度了一下 改为这样

<%
s = "test text"

With Response
.Addheader "Content-Type","text/html; charset=gb2312"
.ContentType= "application/octec-stream"
.AddHeader "Accept-Ranges", "bytes"
.AddHeader "Content-Length", LenB(s)
.AddHeader "Content-Type", "application/octec-stream"
.AddHeader "DownloadOptions", "noopen"
.AddHeader "Content-Disposition","attachment; filename=test.txt"
.BinaryWrite s
End With

%>
漠叔 2009-09-04
  • 打赏
  • 举报
回复
改utf-8也一样
lbcleo 2009-09-04
  • 打赏
  • 举报
回复
如果是文字是乱码,字母正常,如果你要改变模式,改成UTF-8才可以 charset=gb2312 这里去修改一下吧
漠叔 2009-09-04
  • 打赏
  • 举报
回复
楼上的各位高手再帮看看,下载是可以了,但是下载的文件中汉字都成了乱码,页面上显示的时候是正常的,网页编码为gb2312
漠叔 2009-09-04
  • 打赏
  • 举报
回复
唉,改成Write后英文又不行了
漠叔 2009-09-04
  • 打赏
  • 举报
回复
问题解决,改为Response.Write s即可
syjeffdyg 2009-09-03
  • 打赏
  • 举报
回复
其实就是修改头元素head里面的content-type,楼上正解。
hookee 2009-09-03
  • 打赏
  • 举报
回复

<%
s = "test text"

With Response
.Charset = "GB2312"
.ContentType= "application/octec-stream"
.AddHeader "Accept-Ranges", "bytes"
.AddHeader "Content-Length", LenB(s)
.AddHeader "Content-Type", "application/octec-stream"
.AddHeader "DownloadOptions", "noopen"
.AddHeader "Content-Disposition","attachment; filename=test.txt"
.BinaryWrite s
End With

%>

28,391

社区成员

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

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