asp读取远程文件并保存到本地代码(2)


End Function 
Function PostHttpPage(loginActUrl,PostData) 
    Dim xmlHttp 
    Dim RetStr      
    Set xmlHttp = CreateObject("Microsoft.XMLHTTP")  
    xmlHttp.Open "POST", loginActUrl, False
    XmlHTTP.setRequestHeader "Content-Length",Len(PostData) 
    xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"   
    xmlHttp.Send PostData 
    If Err.Number <> 0 Then 
        Set xmlHttp=Nothing
  response.Write("提交登录时出错!提交数据:"&PostData)
        Exit Function
    End If
    PostHttpPage=BytesToBstr(xmlHttp.responseBody,"GB2312")
    Set xmlHttp = nothing
End Function
'''''''''''''''''''''''''''''''''''''''''''
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)
  else
   S.position=Clng(Split(Range,"-")(0))
   Response.BinaryWrite(xml.responseBody)
  End if
  end if
 Response.End  
   Set xml = Nothing
end function
'''''''''''''''''''''''''''''''''''''''''''''''''''''
%>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3258.html