| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 454 人关注过本帖
标题:[求助]求asp的文件下载代码
只看楼主 加入收藏
chenbaichao
Rank: 2
等 级:论坛游民
帖 子:152
专家分:20
注 册:2006-4-11
结帖率:100%
收藏
 问题点数:0 回复次数:2 
[求助]求asp的文件下载代码

求各位大虾
谁能帮我,用asp编写一段从服务器上下载文件的代码
我先给各位谢谢了。

搜索更多相关主题的帖子: asp 文件 代码 
2006-05-29 20:34
icecool
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:20
帖 子:1215
专家分:1376
注 册:2005-3-14
收藏
得分:0 

以下是下载指定文件的一个函数:
strFilename为文件路径


function downloadFile(strFilename)
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
response.end
End Function


http://toorup.3v.do
loading...
2006-05-29 20:41
zhoujianwei
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2006-7-3
收藏
得分:0 

顶下


期待和你交流
2006-08-21 10:21
快速回复:[求助]求asp的文件下载代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013418 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved