<%
'********************************************************** ***********************************
'PageName: GetRemotefiles.asp
'Function: Download The Files To Server
'Author: xiaotian
'Last Modified AT: 2003-3-19
'********************************************************** ***********************************
'Take a remote file and save it to your local
Function GetRemotefiels (RemotePath, LocalPath, FileName)
DIM STRBODY
DIM FilePath
ON Error ResMe next
'Get the stream
Strbody = getBody (RemotePath)
'Get saved file name
IF Right (LocalPath, 1) <> "/" Then LocalPath = localpath & "/"
Filepath = localpath & getFileName (RemotePath, FileName)
'save document
If Savetofile (STRBODY, FILEPATH) = true and err.number = 0 THEN
GetRemoteFiles = TRUE
Else
GetRemoteFiles = false
END IF
END FUNCTION
'Remote acquisition
Function GetBody (URL)
Dim Retrieval
'Establish XMLHTTP object
Set Retrieval = CreateObject ("Microsoft.xmlhttp")
With retrieval
.Open "get", URL, FALSE, "" "" "
Ssend
GetBody = .Responsebody
End with
Set Retrieval = Nothing
END FUNCTION
'Reorganization file name
Function GetFileName (RemotePath, FileName)
DIM Arrtmp
DIM STRFILEXT
Arrtmp = split (remotepath, ".")
StrfileExt = ArrtMP (Ubound (arrtmp))
GetFileName = filename & "." & Strfileext
END FUNCTION
'Save the stream content as a file
Function SaveTofile (Stream, Filepath)
DIM Objstream
ON Error ResMe next
'Establish AdoDb.Stream objects, you must have ADO 2.5 or higher
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, release resources
Set objstream = Nothing
IF err.number <> 0 THENSAVETOFILE = FALSE
Else
Savetofile = true
END IF
END FUNCTION
%>