in reply to (jcwren) RE: amelinda's problem (I am a hardheaded SOB)
in thread amelinda's HTTP/MIME/file upload/not-a-cgi-but-a-client/minimal-module/perl problem

Thanks for being persistent! This is exactly the kind of thing I've been looking for as an example!

I find it kind of interesting that you get around the thing I didn't see in HTML::Form by going and getting the form and then searching it for the right thing and filling it out blindly. I hadn't thought of doing that; it would be good errorchecking - make sure you can get to the site before submitting.

For reference, here is some code I wrote when I was still trying to use libwww-perl (it didn't work, can you tell me why? (serious query)):

#!/usr/bin/perl use HTTP::Request::Common; use LWP::UserAgent; use CGI qw(header -no_debug); my $URL = 'https://www.mydomain.com/upload.html'; my $req = POST $URL, Content_Type => 'form-data', Content => [ user => 'username', pass => 'password', FILE => ['./binaryfile'], # this file will be uploaded ]; my $res = LWP::UserAgent->new->request($req); print header, $res->is_success ? $res->content : $res->status_line;

Yes, yes, Carp, strict, -w and all that. Consider it read, for conciseness' sake. Maybe I'll try it again using HTML::Form.

Replies are listed 'Best First'.
(jcwren) RE: (3) amelinda's problem (I am a hardheaded SOB)
by jcwren (Prior) on Oct 03, 2000 at 04:42 UTC
    Well, it passed the syntax check. Since I don't have a server that's configured to run https, I can't really test it. Perhaps you could describe the error in a little more detail.

    --Chris

    e-mail jcwren