请问用什么方法可以下载asp页面??高分相送!!!

fanzc 2003-12-16 11:43:39
请问用什么方法可以下载asp页面??
如打开一个asp页面点右键查看原代码看不到asp代码,怎么才能让他显示出来???
高分相送!!!
...全文
71 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangzixp 2003-12-22
  • 打赏
  • 举报
回复
call downloadFile(Request.querystring("file"))
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
yown 2003-12-22
  • 打赏
  • 举报
回复
你一定是别有用心喽,当然不会让你下载,尤其asp进行了编码
fanzc 2003-12-22
  • 打赏
  • 举报
回复
真的没有办法下载吗???
heartsea 2003-12-19
  • 打赏
  • 举报
回复
除非你在该服务器上有运行asp的权利,而且服务器支持FSO,或者你安装了什么组件,否则没戏!
剑事 2003-12-19
  • 打赏
  • 举报
回复
极少数人能把 估计方法也不是一般的难

不然ASP该入土了
liefeng123 2003-12-19
  • 打赏
  • 举报
回复
不明白
Ranmei 2003-12-19
  • 打赏
  • 举报
回复
我有见过这样的网站。。。
不过下载下来的文件
已经是静态的网页了.
aoenzh 2003-12-19
  • 打赏
  • 举报
回复
你傻了,
如果能下载 还有人敢用ASP吗?
除非你用黑客程序
fanzc 2003-12-19
  • 打赏
  • 举报
回复
我已经试过此代码,下载不了。
不知道是哪儿的问题??
请问有用此代码下载成功的吗??
请高手指点!!!
flyingding 2003-12-16
  • 打赏
  • 举报
回复
你写一个DL.asp文件,这个文件源码如下:
****************************************
<%
Response.Buffer = true
Response.Clear

'获取要下载的文件在服务器上的绝对位置
dlfile=trim(request("dlfile"))
If dlfile<>"" Then
fileurl=server.MapPath(dlfile)
Else
Response.end
End If

'创建Myfso,使用FSO组件
Set Myfso=Server.CreateObject("Scripting.FileSystemObject")
Set f=Myfso.getfile(fileurl) '定义FSO对象f
fsize=f.size '文件大小
fName=f.name '文件名字
Set f=Nothing '释放f
Set Myfso=Nothing '释放MyFso

'使用Adodb.Stream组件
Set MyStream = Server.CreateObject("ADODB.Stream")
MyStream.Open
MyStream.Type = 1
MyStream.LoadFromFile fileurl

'读取文件类型,让系统识别,以存为不同类型的文件。
Select Case lcase(Right(fName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select

'下载
Response.AddHeader "Content-Disposition", "attachment; filename=" & fName
Response.AddHeader "Content-Length", fsize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite MyStream.Read
Response.Flush

'释放MyStream
MyStream.Close
Set MyStream = Nothing
%>
********************************
然后你在要实现的页面中这样调用:

*****************************************
<a href="dl.asp?dlfile=dl.doc">dl.doc</a>
*****************************************
本源码程序可以下载各种文件,包括asp源码、mp3、htm、TXT等等。

28,407

社区成员

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

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