SaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)保存遠程的文件到本地的代碼
更新時間:2007年09月01日 22:11:07 作者:
'==================================================
'過程名:SaveRemoteFile
'作 用:保存遠程的文件到本地
'參 數(shù):LocalFileName ------ 本地文件名
'參 數(shù):RemoteFileUrl ------ 遠程文件URL
'==================================================
Function SaveRemoteFile(LocalFileName,RemoteFileUrl)
SaveRemoteFile=True
dim Ads,Retrieval,GetRemoteData
On Error Resume Next
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
If .Readystate<>4 or .Status > 300 then
SaveRemoteFile=False
Exit Function
End If
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
'If LenB(GetRemoteData) < 100 Then Exit Function
'If MaxFileSize > 0 Then
'If LenB(GetRemoteData) > 5000 Then Exit Function
Response.Write(Round(LenB(GetRemoteData)/1024)) & "KB"
'End If
Set Ads = Server.CreateObject("Adodb.Stream")
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile server.MapPath(LocalFileName),2
.Cancel()
.Close()
End With
If Err.number<>0 then
SaveRemoteFile=False
Exit Function
Err.Clear
End If
Set Ads=nothing
end Function
'過程名:SaveRemoteFile
'作 用:保存遠程的文件到本地
'參 數(shù):LocalFileName ------ 本地文件名
'參 數(shù):RemoteFileUrl ------ 遠程文件URL
'==================================================
Function SaveRemoteFile(LocalFileName,RemoteFileUrl)
SaveRemoteFile=True
dim Ads,Retrieval,GetRemoteData
On Error Resume Next
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
If .Readystate<>4 or .Status > 300 then
SaveRemoteFile=False
Exit Function
End If
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
'If LenB(GetRemoteData) < 100 Then Exit Function
'If MaxFileSize > 0 Then
'If LenB(GetRemoteData) > 5000 Then Exit Function
Response.Write(Round(LenB(GetRemoteData)/1024)) & "KB"
'End If
Set Ads = Server.CreateObject("Adodb.Stream")
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile server.MapPath(LocalFileName),2
.Cancel()
.Close()
End With
If Err.number<>0 then
SaveRemoteFile=False
Exit Function
Err.Clear
End If
Set Ads=nothing
end Function
相關文章
asp實現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫的方法
asp實現(xiàn)批量插入表單中的數(shù)據(jù)到數(shù)據(jù)庫的方法...2007-08-08
在Win2003 64位下ASP無法連接Access數(shù)據(jù)庫
64位Windows 2003下面配置好IIS后,運行ASP頁面,如果里面有連接access數(shù)據(jù)庫的代碼,就會出現(xiàn)錯誤警告2009-06-06
ASP.Net?MVC利用NPOI導入導出Excel的示例代碼
這篇文章主要介紹了ASP.Net?MVC利用NPOI導入導出Excel的問題記錄,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05
[圖]Flash+ASP實現(xiàn)電子互動地圖在線標注功能
[圖]Flash+ASP實現(xiàn)電子互動地圖在線標注功能...2007-03-03
ASP FSO顯示特殊文件夾的實現(xiàn)代碼(畸形目錄名、UNC路徑)
一些特殊的文件夾asp是沒法完全顯示出來的,但是可以通過unc路徑去刪除,但前提是得知道準確路徑2012-03-03

