On Mon, 25 Nov 2002 19:30:38 +0100, [EMAIL PROTECTED] (Nandita
Shenvi) wrote:

>I have checked the mailing list and some where in 1999 a person had a 
>similar problem and i could not find any appropriate answer to the questions 
>that he had.
>anyway, i will try to explain:
>I want to write  a Perl program to upload a file to a web server. Please 
>note that I'm NOT looking for a script to create a html form with <input 
>type=file> in it,
>and I'm NOT looking for a cgi-script to handle the server side of the 
>upload.There exist a upload.c program on the webserver. What I'm looking for 
>is a standalone program  that connects to a web server and uploads a file.
>

#!/usr/bin/perl
use warnings;
use strict;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

my $url ='http://zentara.zentara.net/~zentara/cgi-bin/uploadz';
my $file = 'testout.tgz';

my $ua = new LWP::UserAgent;

my $req = POST $url,
Content_Type => 'multipart/form-data',
Content => [
file => [$file]
];

my $res = $ua->request($req);
if ($res->is_success){print $res->as_string;
}else{print $res->status_line;
}
exit 0;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to