upload file programmatically on to http server - TCP-IP

This is a discussion on upload file programmatically on to http server - TCP-IP ; Dear group members, I want to upload a file onto the server but don't want to use the help of forms. I want to do the same from opening the conenction from command line and do everything from there on. ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: upload file programmatically on to http server

  1. upload file programmatically on to http server

    Dear group members,

    I want to upload a file onto the server but don't want to use the help
    of forms. I want to do the
    same from opening the conenction from command line and do everything
    from there on.

    Here is my header info

    POST /fileupload.php HTTP/1.1
    User-Agent: Mozilla/5.0
    Host: xx.xx.xx.xx
    Accept:
    text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q*=0.8,image/png,*/*;q=0.5

    Accept-Language: en-us,en;q=0.5
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Content-Disposition: attachment; userfile=A.h
    Content-length: 81


    Where fileupad.php looks like ******************
    // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used
    instead
    // of $_FILES.

    $uploaddir = '/var/www/uploads/';
    $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

    echo '
    ';
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

    echo "File is valid, and was successfully uploaded.\n";

    } else {

    echo "Possible file upload attack!\n";
    }

    echo 'Here is some more debugging info:';
    print_r($_FILES);

    print "
    ";

    ?>
    ************************************************** ****


    What I noticed that the association between variable "userfile" defined
    in Content-Disposition
    header and the variable "usrfile" in the php script does not get
    created.

    Can someone help me in creating this association or pointing out the
    missing step.\

    Thanks in advance.


    nagrik


  2. Re: upload file programmatically on to http server


    Vinay Nagrik wrote:

    > What I noticed that the association between variable "userfile" defined
    > in Content-Disposition
    > header and the variable "usrfile" in the php script does not get
    > created.
    >
    > Can someone help me in creating this association or pointing out the
    > missing step.\


    I believe PHP<->CGI puts all the posted variables in an associative
    array called $HTTP_POST_VARS, so what you want is
    $HTTP_POST_VARS['userfile'].

    Also, make sure you are consistent. Unfortunately, 'userfile' is not
    the same as 'usrfile'.

    DS


+ Reply to Thread