Created
September 28, 2011 02:18
-
-
Save fukata/1246825 to your computer and use it in GitHub Desktop.
Post file and data use LWP::UserAgent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use Encode; | |
use HTTP::Request::Common; | |
use LWP::UserAgent; | |
my $ua = LWP::UserAgent->new; | |
$ua->agent('FUKATA/1.0 '); | |
my $data = { | |
name = '深田達也', | |
description = 'ニートになりたいプログラマ', | |
icon => ['/tmp/icon.png'], | |
}; | |
$data->{$_} = Encode::encode('utf8', $data->{$_}) for qw/name description/; | |
my $post_url = 'http://localhost/dump.php'; | |
my $res = $ua->request(POST( | |
$post_url, | |
Content_Type => 'form-data', | |
Content => $data, | |
)); | |
print $res->content; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment