xmlHTTP ile dosya Transferi



<%
    'Create a list of URLS of where the information that you want to save on your server is located.
    TheURLS = "http://www.tknw.com/chrcodes.asp|" & _
              "http://www.thermokingnw.com/img/ClubCar/StreetRodFlame.jpg|" & _
              "http://www.cumminsnorthwest.com/PubDown.asp?Doc=OnanDown/MicroLite2880.pdf|" & _
              "http://www.buffaloruncampground.com/gfx/map.jpg"
    
    'Create a coresponding list of file names that you would like the files saved as.
    FileNames = "chrcodes.asp|" & _
                "StreetRodFlame.jpg|"  & _
                "MicroLite2880.pdf|" & _
                "BuffaloRunCampgroundMap.jpg"

    'Create the arrays of file locations and save names
    FileURL = Split(TheURLS,"|")
    SaveName =  Split(FileNames,"|")

    'Set xmlHTTP
    Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP")
    'Cycle through the file locations and save them
    For x = 0 to UBound(FileURL)

       'Get the file
       xmlHTTP.open "GET", FileURL(x), false
       xmlHTTP.send()
        
       'Download the file
         set DataStream = CreateObject("ADODB.Stream")
         DataStream.Open
         DataStream.Type = 1 'adTypeBinary  
         DataStream.Write xmlHTTP.ResponseBody
         DataStream.Position = 0
       
       'Set the location of where you want the file saved.
       SavedFile = "D:\Stuff\" & SaveName(x)

       'Set the File System Object, so we can check to see if it already exists.
         set FSO = Createobject("Scripting.FileSystemObject")
         'If the file already exists, delete it
       if fso.Fileexists(SavedFile) then
          Fso.DeleteFile SavedFile
       End If
         set FSO = Nothing
       
       'Write the file to the location on the server
         DataStream.SaveToFile SavedFile
         DataStream.Close
         Set DataStream = Nothing

    Next
   Set xmlHTTP = Nothing
%>