Problem with file-upload using HTTP::Request::Common

Discussion in 'Perl Misc' started by Alex, Mar 19, 2006.

  1. Alex

    Alex Guest

    I have read many of the other threads on this topic, but none quite
    seem to answer my query - any advice would therefore be greatly
    appreciated.

    I have a form with about 20 parameters on, one of which is a file
    upload field. If i submit this form directly to the MASCOT fileserver,
    it functions correctly - all parameters and their values are passed.

    However, if I convert the form into a self-targetting form, capture all
    the parameters and their values (using $cgi_obj->Vars(); ), and then
    pass the resulting hash reference to:

    my $request = POST 'http://my/url/here/prog.exe',
    Content_Type => 'form-data',
    Content => $param_hash_reference;

    : in this case the server complains that the file did not exist or i
    entered no data.
    (i'm doing this so i can capture the html returned from the file-server
    in a response object. I have already created the necessary UA object.)

    I have read the HTTP::Request::Common docs repeatedly, and experimented
    with all the methods demonstated there, but i cannot suceed in making
    it work. Any pointers/suggestions as to where i'm going wrong are
    therefore appreciated.
    Please be assured this is a last resort, and I am not intending to
    waste anyone's time.

    Thanks and Regards

    Alex
    Alex, Mar 19, 2006
    #1
    1. Advertising

  2. Alex wrote:
    > if I convert the form into a self-targetting form, capture all
    > the parameters and their values (using $cgi_obj->Vars(); ), and then
    > pass the resulting hash reference to:
    >
    > my $request = POST 'http://my/url/here/prog.exe',
    > Content_Type => 'form-data',
    > Content => $param_hash_reference;
    >
    > : in this case the server complains that the file did not exist or i
    > entered no data.
    > (i'm doing this so i can capture the html returned from the file-server
    > in a response object. I have already created the necessary UA object.)
    >
    > I have read the HTTP::Request::Common docs repeatedly, and experimented
    > with all the methods demonstated there, but i cannot suceed in making
    > it work. Any pointers/suggestions as to where i'm going wrong are
    > therefore appreciated.


    I believe you are going wrong already by using the CGI::Vars() method.
    AFAIK, that method can't be used to parse a file upload request, since
    the values of the file select controls aren't also file handles.

    Probably you need to save the file, parse the other parameters, and
    create a fresh file upload request.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Mar 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sure
    Replies:
    1
    Views:
    586
    Jim Gibson
    Sep 2, 2004
  2. Denny
    Replies:
    1
    Views:
    774
  3. Some Guy

    need help with HTTP::Request::Common

    Some Guy, Mar 12, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    332
    Tad McClellan
    Mar 13, 2005
  4. Replies:
    9
    Views:
    261
    Charles DeRykus
    Mar 14, 2006
  5. Replies:
    1
    Views:
    221
    zentara
    Nov 6, 2006
Loading...

Share This Page