Jump to content

Warspite

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Warspite

  1. > Can you find any rules or security settings that would explain that?

     

    I don't think so; not even sure where to look. I just assumed (because I can send text data) I could also send a file and automate the process

    without needing to run up cuteftp. Maybe I was a bit ambitious...  and in an area I know nothing about.  But thanks for trying.

    Cronix, will remember about code tags.

  2. OK. There's much more to this, apparently.   Perhaps I cannot do what I'm attempting...

     

    The full routine now is

     

    Function WinHTTPPostRequest(URL, theFile)
      Dim http

      Set http = CreateObject("WinHttp.WinHttprequest.5.1")
     
      http.Open "POST", URL & "?filename=" & theFile, False
       
      http.setRequestHeader "Content-Type", "application/zip"
     
      http.send ("Post data")
     
      'Get a result of the script which has received upload
      WinHTTPPostRequest = http.responseText
      Debug.Print http.responseText
    End Function

     

     

    Th response is now

     

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>403 Forbidden</title>
    </head><body>
    <h1>Forbidden</h1>
    <p>You don't have permission to access /files/site/
    on this server.</p>
    <hr>

     

    What do I need to do to "be allowed" or "have permission " ?

     

    Would showing you the routine which does "allow" me to send data (instead of a zip file)

    be useful ?

  3. A liitle more to add, found an example of the Send Method and tried it just to see results

     

     http.send ("Post data")

     

    Now the respose text is very different, and says

     

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>405 Method Not Allowed</title>
    </head><body>
    <h1>Method Not Allowed</h1>
    <p>The requested method PUT is not allowed for the URL /files/site/.</p>
    <hr>
     

  4. Continuing on, I did some Googling and found a bit about URL-encoded filenames. I found a site that did the conversion and

     

    "C:\ZipTest\tester.zip" became "C%3A%5CZipTest%5Ctester.zip"

     

    But  another site reported the "." should be "%2E"  Afaik that's decimal 46 and is part of the ascii character set ?

     

    I tried both but the same error resulted

     

    This method cannot be called until the Send method has been called

  5. >All you did to the uploading code was change that one http.Open line to the new one, right?

     

    Yes

     

    >You also have to substitute "URL_encoded_filename_goes_here", which I wrote in the hopes that you would read that name and realize you were supposed to put the URL-encoded filename there >and not just copy/paste it blindly.

     

    Fair comment, but I did say I'm not sure what a 'URL_encoded_filename' is. I used my 'best guess' to what it might be.

    If you could tell me I'll certainly try.  Would that also sort the error message about the Send method ?

  6. Many thanks..  wish i could follow what you mean as well as you!   I did try your example

    http.Open "PUT", URL & "?filename=" & URL_encoded_filename_goes_here, False

    and received error  "This method cannot be called until the Send method has been called"

     

    I am flying completetly blind here, first up I'm not sure what a 'URL_encoded_filename' is and I was just using

    the normal filespec 'C:\ZipTest\tt.zip'.

     

    If you're Ok to help (and I hope you are!) can we do this in 2 stages, first get the zip file onto the site

    then the php code to move it to the required destination.  Or maybe that all happens in one hit?. The other php code I

    have (the one I was trying to adapt) does stuff this doesn't need.  Maybe there's nothing needed on the site at all ?

  7. Thanks boompa,  took a look at both but it's all a bit too complex for me.  I assume there's the routine to send the file (on my local machine) and

    a routine (php) on the website to receive it and copy somewhere?  But I can't find anything along those lines... so I'll keep using FTP for now.

    But if anyone has an example I could follow I'd like to give it a go.

  8. Yes, I can change anything.  The uploading code is (and doesn't quite work) is

    ---

    Function WinHTTPPostRequest(URL, theFile)
      Dim http

      Set http = CreateObject("WinHttp.WinHttprequest.5.1")
     
      'Open URL As POST request
      http.Open "POST", URL, False
     
      'Send theFile data To URL As POST binary request
      http.send theFile
     
      'Get a result of the script which has received upload
      WinHTTPPostRequest = http.responseText
      Debug.Print http.responseText
    End Function

    ---

    It returns "Forbidden' or somesuch and I presume that's a fair-enough security thing.  I can attempt to resolve that, but I do have working

    php script which accepts a string send by WinHttp.WinHttprequest.5.1 (and appends to on text file on the website + sends a notify email).  It's this I'm trying to adapt

    to accepting a zip file and saving it to somwhere on the site.

  9. Sorry, I do not know anything about php, except that I need to (try) make this work

     

    <?php
    $uploads_dir = '/uploads';
    foreach ($_FILES["pictures"]["error"] as $key => $error) {
        if ($error == UPLOAD_ERR_OK) {
            $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
            $name = $_FILES["pictures"]["name"][$key];
            move_uploaded_file($tmp_name, "$uploads_dir/$name");
        }
    }
    ?>

     

    What i hope to achieve is move a file Posted via WinHttp.WinHttpRequest.5.1 to a target folder.

    There is no '/Uploads' folder as such but I could make one.  All the above is an example from

    Google, there's no "pictures" or "tmp_name".  The file is a .zip file.

     

    Any help greatly appreciated.

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.