LWP Perl file uploader
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
upload($ARGV[0], 'http://filelayer.com');
sub upload {
my ($source, $target) = @_;
my $ua = LWP::UserAgent->new();
$ua->timeout(5);
my $rs = $ua->request(
POST $target,
Content_Type => 'form-data',
Content => ['file[file]' => [$source]]
);
print $rs->error . "\n" if $rs->is_error;
}
zobrazení: