'============================================================.
'Nom du processus: Saveremotefile
'Fonction: enregistrez les fichiers distants vers local
'Paramètre: LocalFileName ------ Nom du fichier local
'Paramètres: RemoteFileUrl ----- URL du fichier à distance
'============================================================.
FunctionSaveleMoteFile (localFilename, RemoteFileUrl)
SaveremoteFile = True
Dimads, récupération, getRemotedata
Onerrorresumenext
SetRetrieval = server.createObject ("Microsoft.xmlhttp")
Avec un peu de temps
.Open "Get", RemoteFileUrl, False, "", ""
.Envoyer
If.readystate <> 4or.status> 300Then
Saveremotefile = False
Sortie
Endire
GetReMoteData = .ResponseBody
Fin
SetRetrieval = rien
'Iflenb (getRemotedata) <100ThenexitFunction
'Ifmaxfilesize> 0
'Iflenb (getRemotedata)> 5000ThenexitFunction
Response.Write (Round (LENB (GetRemotedata) / 1024)) & "KB"
'Endif
Setads = server.createObject ("adodb.stream")
Withads
.Type = 1
.Ouvrir
.WriteGetRemotedata
.SavetoFileSserver.Mappath (localFilename), 2
.Annuler()
.Fermer()
Fin
IFerr.Number <> 0THEN
Saveremotefile = False
Sortie
Err.Clear
Endire
Setads = rien
finition de fin