G'day,
I've got a CGI script that accepts a form, including a file handle,
hence allowing users to upload files, but I'm having trouble passing the
request in a URL request. The request is generated by a script using
HTTP (no HTML is used in the process), and works with the LWP module by
having something like the following in the client (showing only
essential detail):
use LWP;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
my $res = $ua->request(
POST $external_url,
Content_Type => 'form-data',
Content =>
[
upload_file => [ $filepath ],
user => $userid,
action => $action,
]
);
So the above client code works fine, but the following alternative fails:
my $req = HTTP::Request->new(POST => "$external_url");
$req->content_type('application/x-www-form-urlencoded');
$req->content("upload_file=$filepath&user=$userid&action=$action");
my $res = $ua->request($req);
On the server side, the CGI scipt basically loads the uploaded file via
(showing only essential detail):
use CGI qw(:standard);
my $q = new CGI;
my $fh_payload = $q->upload('upload_file');
Is there any reason why the second method (using the encoded URL) fails
while the first method succeeds? More importantly, can anyone suggest a
way of making the second method work?
Cheers,
Mark
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>