找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 89|回复: 1

阳光白雪的实现文件下载怎样弄的。

[复制链接]
发表于 2010-1-17 06:22:49 | 显示全部楼层 |阅读模式 IP:江苏扬州
我下载了阳光白雪的实现文件下载函数,以下是过程,报找不到文件:
第一个文件123.htm 内容:
<a href="load.asp?filename=123.txt">1231</a>
第二个文件:
<%
'**************************************************************
'**使用方法: **
'**在点击下载处加连接<a href="load.asp?filename=文件名"></a> **
'**阳光白雪——2005年11月21日 **
'**E-mail:chenmanyi0818@126.com **
'**HomePage:http://dnjy.2000y.com **
'**************************************************************
'**************************************************
'** 实现文件下载函数 **
'**************************************************
Function Filedownload(filename)
Dim strchar,fliesend,objectFile,objfile,objStream,path,pathtype
pathtype = "application/x-msdownload"
path = server.MapPath("download/"&filename)
Const loadfilesize=32768 '32KB,也可取其它值,单位:字节
'在给path赋值后,其最终值必定是该图片在服务器端存储器上的绝对路径,如 C:\Inetpub\wwwroot\pic\help.gif
'因为 server.MapPath 取得的只是站点根目录的路径,所以在后面还应加上文件所在的文件夹再加文件名
'例如:要下载的文件 setup.exe 在根目录的 download 文件夹下,则 path = server.MapPath("download/"&filename)
'***********************************
'测试用
'response.Write(path)
'response.Write(filename)
'response.End()
'***********************************
fliesend=0
TransferFile = True
Set objectFile = Server.CreateObject("Scripting.FileSystemObject")
Set objfile = objectFile.GetFile(Path)
Set objStream = objfile.OpenAsTextStream(1,-1)
Response.AddHeader "content-type", pathtype
response.AddHeader "Content-Disposition","attachment;filename="&filename
Response.AddHeader "content-length", objfile.Size
Do While Not objStream.AtEndOfStream
strchar = objStream.Read(1)
Response.BinaryWrite(strchar)
fliesend = fliesend + 1
If (fliesend MOD loadfilesize) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
end if
objStream.Close
Set objStream = Nothing
Set objectFile = Nothing
End Function
'****************************************************
'** 文件下载函数结束 **
'****************************************************
Dim fileneme,downloadfile
filename = request("filename") '此处的 filename 仅为下载文件的名称(包括扩展名)
downloadfile = Filedownload(filename) '调用文件下载函数
Response.End
%>
不知道怎样实现的,我看不懂,但我想了解
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 15:36 , Processed in 0.145154 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表