求救,求救!我快死了

yyq136 2004-08-31 10:17:39
我是一个超级新手,老板要强求一个实现下载的功能!
有谁能帮帮我让我度过难关,提供一下具有下载功能的源代码。
帮帮忙,各位!!!
...全文
92 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
银狐被占用 2004-08-31
  • 打赏
  • 举报
回复
有太多了!

好好找找!!!
超级大笨狼 2004-08-31
  • 打赏
  • 举报
回复

<%
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "无效文件名."
Response.End
End if
' 下面是不希望下载的文件
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "受保护文件,不能下载."
Response.End
End Select
' 下载这个文件
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & FileName
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile Server.MapPath(FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>
jyzxpboy 2004-08-31
  • 打赏
  • 举报
回复
网上多得要死,随便找一个网站asp源代码呀
yiyioo 2004-08-31
  • 打赏
  • 举报
回复
1.asp

<a href="2.asp?filepath="路径"">download</a>

2.asp

filepath=request("filepath")

call downloadFile(filepath)

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>错误:</h1>" & strFilename & " 文件不存在!<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
风之银翼 2004-08-31
  • 打赏
  • 举报
回复
www.zuying.com
里面有很多asp源代码!!
海大富运动 2004-08-31
  • 打赏
  • 举报
回复
类似网站很多的!我来接分的,呵呵……
ryuginka 2004-08-31
  • 打赏
  • 举报
回复
www.chinaz.com/download
你到ASP源代码中找吧
caiyi000 2004-08-31
  • 打赏
  • 举报
回复
很多代码的。去搜索一下就能找到啊。我晕。
甘泉123 2004-08-31
  • 打赏
  • 举报
回复
http://www.asp300.com/CodeView/CodeView_4252.html
这是一个,网上类似的有很多~

28,390

社区成员

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

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