<%
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<>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="遠程文件名(絕對全路徑)
localfile=Replace(Replace(Replace(Now(),"-","")," ",""),":","")&Right(remoteurl,4)'本機文件名(可自定義)
If SaveRemoteFile(localfile,remoteurl)=True Then
Response.Write("成功保存:"&localfile)
End If
%>