function dl(f,n)
on error resume next
set s=createobject("adodb.stream")
s.mode=3
s.type=1
s.open
s.loadfromfile(f)
if err.number>0 then
response.status="404"
else
response.contenttype="application/octet-stream"
response.addheader "content-disposition:","attachment; filename=" & n
range=mid(request.servervariables("http_range"),7)
if range="" then
response.binarywrite(s.read)
else
s.position=clng(split(range,"-")(0))
response.binarywrite(s.read)
end if
end if
response.end
end function
函数使用示例:
call dl(server.mappath("../download/07.zip"),"07.zip")