通过链接下载txt文件而不是打开它,怎么写?(内空)

Roxxette 2004-09-23 03:47:26
...全文
156 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dsclub 2004-09-24
  • 打赏
  • 举报
回复
关注!
ttkkyy 2004-09-23
  • 打赏
  • 举报
回复

<%
response.redirect "/User_data/20040305/info/5/295-1.rar"

%>
Roxxette 2004-09-23
  • 打赏
  • 举报
回复
没这么复杂吧?有没有简单点的办法?
我还以为只是两三个字符就可以搞定的问题呢。
分不够可以再加码,大虾们不要太小气啊
ttkkyy 2004-09-23
  • 打赏
  • 举报
回复
<%

function downloadFile(strFile)
strFilename = server.MapPath(strFile)

Response.Buffer = True
Response.Clear

Set s = Server.CreateObject("ADODB.Stream")
s.Open

s.Type = 1

on error resume next


Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
Response.End
end if


Set f = fso.GetFile(strFilename)
intFilelength = f.size


s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if

Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"

Response.BinaryWrite s.Read
Response.Flush


s.Close
Set s = Nothing


End Function

call downloadFile("/User_data/20040305/info/5/295-1.rar")

%>
cpio 2004-09-23
  • 打赏
  • 举报
回复
分太少,不告诉你

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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