孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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")

posted on 2008-09-19 14:54  孤独的猫  阅读(523)  评论(0编辑  收藏  举报