%
host=Request.ServerVariables("HTTP_HOST")
fwym="http://" host Request.ServerVariables("SCRIPT_NAME")
wenjian=request("wenjian")
select case true
case right(lcase(wenjian),4)=".asp"
response.write "该类型文件不容许 下载。"
response.end
case right(lcase(wenjian),4)=".php"
response.write "该类型文件不容许 下载。"
response.end
case right(lcase(wenjian),5)=".aspx"
response.write "该类型文件不容许 下载。"
response.end
end select
wenjian=replace(wenjian,"/","\")
a=split(wenjian,"\")
filename=a(ubound(a))
Set fso = CreateObject("Scripting.FileSystemObject")
fileurl=left(fwym,len(fwym)-8) wenjian
fileurl=replace(fileurl,"\","/")
if instr(1,wenjian,":")=0 then wenjian=server.mappath(wenjian)
'设置可下载文件大小上限
maxsize=50000000
'response.write wenjian
'response.end
set f1=fso.getfile(wenjian)
if f1.sizemaxsize then
response.write "文件太大了,不容许 下载。" dxzh(f1.size) "只撑持" dxzh(maxsize) "以内的文件下载"
response.end
end if
if instr(1,wenjian,":")=0 then
'response.write fileurl
response.redirect fileurl
response.end
end if
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename =" filename
set objstream = Server.CreateObject("adodb.stream")
objstream.Mode = 3
objstream.Type = 1
objstream.Open
objstream.LoadFromFile (wenjian)
BytesToBstr = objstream.Read
response.binarywrite BytesToBstr
function dxzh(dx)
zijieshu = dx "字节"
kbshu = FormatNumber(dx / 1024, "0.0") "KB"
mbshu = FormatNumber(dx / 1024 / 1024, 2) "MB"
fsize = dx
If fsize / 1024 1 Then dxzh = zijieshu
If fsize / 1024 = 1 And fsize / 1024 1024 Then dxzh = kbshu
If fsize / 1024 = 1024 Then dxzh = mbshu
end function
%
概述在ASP网站中文件下载功用若何实现?文件下载只是个超链接,下载功用关键 是和上传功用搭配利用,当上传完毕以后,法式主动将上传的文件所在位置链接保留到数据库,如许下载的时候间接读取翻开链接即可下载!
谁介绍几个好的asp源码下载网站论坛也能够1、源码之家
2、代码中国网
3、源码全国
4、站长网
5、源码网
6、中国站长下载-源码下载
7、ASP300
8、ASP酷法式下载中心
9、洪越源代码
10、114软件源码下载
11、中国代码网
12、曾子源码软件下载
13、锋网源码
15、中华源码网
16、源码喜好者
18、动站源码下载
20、CodeGuru - Visual C++