保存远程的文件到本地的ASP代码。

File:Get.asp
'==================================================
'过程名:SaveRemoteFile
'作 用:保存远程的文件到本地
'参 数:LocalFileName ------ 本地文件名
' RemoteFileUrl ------ 远程文件URL
'==================================================
sub SaveRemoteFile(LocalFileName,RemoteFileUrl)
dim Ads,Retrieval,GetRemoteData
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set Ads = Server.CreateObject("Adodb.Stream")
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile server.MapPath("pic/"&LocalFileName),2
.Cancel()
.Close()
End With
Set Ads=nothing
end sub

调用: SaveRemoteFile "test.gif","/images/logo.gif"

标签: none

已有 2 条评论

  1. Adodb.Stream的原因吧..够敏感...

  2. 此段代码在Reader里有木马提示:

    木马程序(修改):
    Trojan-Downloader.JS.Gen
    文件:
    http://www.google.com/reader/atom/feed/http%3A%2F%2Fwww.chener.net%2Fblog%2Frss.php?r=n&n=20&ck=1186831570125&client=scroll/http%3A%2F%2Fwww.chener.net%2Fblog%2Frss

    直接浏览没问题,不知是不是RSS未输出全文的原因?

评论已关闭