#14 'multipart/form-data' submissions

open
nobody
None
5
2002-10-17
2002-10-17
Hetal Trivedi
No

I need to make use of snoopy for submiting a form to a
remote URL with a file attachment. The submission shall
be thru' HTTPS. How does one go about making an
attachment of an XML/SOAP document attached to a
form.
Any help shall be greatly appreciated.

Discussion

  • Neil Munro
    Neil Munro
    2003-12-18

    Logged In: YES
    user_id=933649

    <p>It's very easy when you know how...
    <code>
    include "Snoopy.class.php";
    $snoopy = new Snoopy;
    $vars=array();
    //OPTIONAL: form POST parameters e.g. $vars["upload"] = "1";
    $upload_files["userfile"] = "/here/file.txt";
    $snoopy->set_submit_multipart();
    $snoopy->submit
    ("http://site.com/upload.php",$vars,$upload_files);
    </code>

    <p>At the other end in upload.php:

    <code>
    //OPTIONAL: test form parameters e.g. if(isset($_POST
    ["upload"])) ...
    if($_FILES['userfile']['size'] != 0) //should also check type,
    max size, etc.
    copy($_FILES['userfile']['tmp_name'],"/there/.$_FILES
    ['userfile']['name']");
    </code>

    Neil Munro (neil.munro A T catalyse.net)