首页 > 网站 > 建站经验 > 正文

A,SP保存远程文件到本地

2019-11-02 15:12:19
字体:
来源:转载
供稿:网友

 <%

Function SaveRemoteFile(LocalFileName,RemoteFileUrl)
    SaveRemoteFile=True
dim Ads,Retrieval,GetRemoteData
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
   .Open "Get", RemoteFileUrl, False, "", ""
   .Send
        If .Readystate<

手机电影网[www.aikan.tv/special/shoujidianyingwang/]
>4 then
            SaveRemoteFile=False
            Exit Function
        End If
   GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set Ads = Server.CreateObject("Adodb.Stream")
With Ads
   .Type = 1
   .Open
   .Write GetRemoteData
   .SaveToFile server.MapPath(LocalFileName),2
   .Cancel()
   .Close()
End With
Set Ads=nothing
End Function
%>

<%
'以下为调用示例:
remoteurl="http://www.uyux.cn/logo.gif"'远程文件名(绝对全路径)
localfile=Replace(Replace(Replace(Now(),"-","")," ",""),":","")&Right(remoteurl,4)'本机文件名(可自定义)
If SaveRemoteFile(localfile,remoteurl)=True Then
Response.Write("成功保存:"&localfile)
End If
%>

-

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表