龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp编程 >

asp下载远程文件保存函数

时间:2009-12-21 11:47来源:未知 作者:admin 点击:
分享到:
下载远程文件 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
精彩图集

赞助商链接