Skip to content

Instantly share code, notes, and snippets.

@typester
Created December 14, 2009 09:24
Show Gist options
  • Save typester/255928 to your computer and use it in GitHub Desktop.
Save typester/255928 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use HTTP::Request::Common;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new( stack_depth => 1 );
# login
my $req = POST 'http://localhost:10808', [
g2_controller => 'remote:GalleryRemote',
'g2_form[cmd]' => 'login',
'g2_form[uname]' => 'scott',
'g2_form[password]' => 'tiger',
];
$mech->request($req);
# add-item
$req = POST 'http://localhost:10808',
Content_Type => 'form-data',
Content => [
g2_controller => 'remote:GalleryRemote',
'g2_form[cmd]' => 'add-item',
g2_userfile => [$ARGV[0] || die]
];
$mech->request($req);
warn $mech->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment