您的位置:首页 > 其它

利用Stream下载文件

2008-09-19 14:54 218 查看
Function dl(f,n)

On error resume Next

Set s=CreateObject("Adodb.Stream")

s.Mode=3

s.Type=1

s.Open

s.Loadformfile(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

函数调用实例

call dl(Server.MapPath("text.zip"),"test.zip")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: