posto una versione funzionante, bello script.
codice:
<%
'************************************************* ***************************
'PageName: GetRemoteFiles.asp
'Function: Download the files to Server
'Author: xiaotian
'Last Modified at :2003-3-19
'************************************************* ***************************
'Access to remote files and save to the local
Function GetRemoteFiles (RemotePath, LocalPath, FileName)
Dim strBody
Dim FilePath
'On Error Resume Next
'To obtain flow
strBody = GetBody(RemotePath)
'Made to preserve the file name
'if Right (LocalPath, 1) <> "\" then LocalPath = LocalPath & "\"
FilePath = LocalPath & GetFileName (RemotePath, FileName)
'Save the file
if (SaveToFile(strBody, Server.MapPath(FilePath)) = true) then
GetRemoteFiles = true
else
GetRemoteFiles = false
end if
End Function
'Remote access to the content
Function GetBody (url)
Dim Retrieval
'The establishment of XMLHTTP object
Set Retrieval = CreateObject ( "Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody =.ResponseBody
End With
Set Retrieval = Nothing
End Function
'Restructuring of the file name
Function GetFileName (RemotePath, FileName)
Dim arrTmp
Dim strFileExt
arrTmp = Split (RemotePath, ".")
strFileExt = arrTmp (UBound (arrTmp))
GetFileName = FileName & "." & StrFileExt
End Function
'Will be saved as a file stream content
Function SaveToFile (Stream, FilePath)
Dim objStream
'On Error Resume Next
'ADODB.Stream object to establish, it is necessary to ADO 2.5 or later
Set objStream = Server.CreateObject ( "ADODB.Stream")
objStream.Type = 1 'open in binary mode
objStream.Open
objstream.write Stream
objstream.SaveToFile FilePath, 2
objstream.Close ()
'Close the object and release resources
Set objstream = Nothing
if err.Number <> 0 then
SaveToFile = false
else
SaveToFile = true
end if
End Function
Response.Write(GetRemoteFiles("http://www.lucavizzi.it/immagini/logomaps.jpg","\public\","StolenImage"))'se ok scrive "True"
%>