LWP Perl file uploader


stáhnout snippet
zobrazení: SyntaxHighlighter | GeSHi | Holý text
#!/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;
}


Tagy:
perl 24 řádků | 2008-09-25 03:24:11 | air.kadlec@seznam.cz