首页 > 应用开发 > IT综合 > 用流(stream)技术做下载 (转)
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")
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-958742/ ,如需转载,请注明出处,否则将追究法律责任。