Copying a file from another server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lysander
    Recognized Expert Contributor
    • Apr 2007
    • 344

    Copying a file from another server

    Hi,
    ASP is not my strongest subject. I am sure this must be easy-peasy to do but I can't get anywhere.

    I have my own IIS server, running an ASP application.

    I need to copy several files from somewhere on the web to my local server, where I can then process them. I know I am allowed to do this, as the web site concerened just says autocopy scripts must not be run more than once per hour.
    This is one of the files I need to copy.

    "http://en6.tribalwars. net/map/village.txt"

    The best I could come up with was
    [code=asp]
    <%option explicit
    dim fso
    Set fso = CreateObject("S cripting.FileSy stemObject")
    'rename live database
    fso.CopyFile "http://en6.tribalwars. net/map/village.txt","C :\t.txt"
    set fso=nothing
    %>
    [/code]
    But it dont want to know..

    I can go to the site and download the files from there, but there are dozens of them, and I want to do this on a daily basis.

    Any hints please.
  • AricC
    Recognized Expert Top Contributor
    • Oct 2006
    • 1885

    #2
    I don't know if you can pass copyfile a url try using a path

    check this
    http://www.w3schools.c om/asp/met_copyfile.as p

    Comment

    • Lysander
      Recognized Expert Contributor
      • Apr 2007
      • 344

      #3
      Originally posted by AricC
      I don't know if you can pass copyfile a url try using a path

      check this
      http://www.w3schools.c om/asp/met_copyfile.as p
      Nope, you can't. I get the error
      'Bad file name or number'

      There must be an easy way to do this, I mean, thats what every browser does when you type in a url

      Comment

      • Lysander
        Recognized Expert Contributor
        • Apr 2007
        • 344

        #4
        Found a solution on another site. This works. Now I just need to work out how to unzip it in code. (This is not the actual file I am after)

        [code=vb]
        <%

        Response.Buffer = True
        Dim objXMLHTTP, xml
        Set xml = Server.CreateOb ject("Microsoft .XMLHTTP")

        xml.Open "GET", _
        "http://www.4guysfromro lla.com/webtech/code/mitchell-pres.zip", _
        False

        xml.Send

        set oStream = createobject("A dodb.Stream")
        Const adTypeBinary = 1
        Const adSaveCreateOve rWrite = 2
        Const adSaveCreateNot Exist = 1
        oStream.type = adTypeBinary
        oStream.open
        oStream.write xml.responseBod y
        oStream.savetof ile "C:\" & "Test.zip", adSaveCreateOve rWrite

        oStream.close

        set oStream = nothing

        Set xml = Nothing

        %>
        [/code]

        Comment

        Working...