ASP implementation of Saveremotefile function save remote file to local code _ Application Tips
Source: Internet
Author: User
'==================================================
' Procedure name: Saveremotefile
' Function: Save remote files to local
' Parameter: localfilename------local filename
' Parameter: remotefileurl------remote File 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 > Then
Saveremotefile=false
Exit Function
End If
Getremotedata =. Responsebody
End With
Set retrieval = Nothing
' If LenB (getremotedata) < 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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.