asp下载远程文件保存函数
下载远程文件 url:远程文件路径,filename:保存文件名 function DownloadFile(url,filename) Set xml = Server.CreateObject("Msxml2.XMLHTTP") 创建对象 xml.Open "GET",url,False xml.Send 发送请求 if Err.Number0 then Response
'下载远程文件
'url:远程文件路径,filename:保存文件名
function DownloadFile(url,filename)
Set xml = Server.CreateObject("Msxml2.XMLHTTP") '创建对象
xml.Open "GET",url,False
xml.Send '发送请求
if Err.Number>0 then
Response.Status="404"
else
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","attachment; filename=" & filename
Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
if Range="" then
Response.BinaryWrite(xml.responseBody)
'response.Write xml.responseBody
else
S.position=Clng(Split(Range,"-")(0))
' Response.BinaryWrite(xml.responseBody)
response.Write xml.responseBody
End if
end if
Response.End
Set xml = Nothing
end function
'url:远程文件路径,filename:保存文件名
function DownloadFile(url,filename)
Set xml = Server.CreateObject("Msxml2.XMLHTTP") '创建对象
xml.Open "GET",url,False
xml.Send '发送请求
if Err.Number>0 then
Response.Status="404"
else
Response.ContentType="application/octet-stream"
Response.AddHeader "Content-Disposition:","attachment; filename=" & filename
Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
if Range="" then
Response.BinaryWrite(xml.responseBody)
'response.Write xml.responseBody
else
S.position=Clng(Split(Range,"-")(0))
' Response.BinaryWrite(xml.responseBody)
response.Write xml.responseBody
End if
end if
Response.End
Set xml = Nothing
end function
收藏文章
精彩图集