Según el manual de WWW::Mechanize, el valor de la ruta completa a la imagen debe pasarse al campo del formulario correspondiente.
Por Internet, he visto dos maneras:
1.-
WWW::Mechanize for uploading files Usa el truco de utilizar el método
post, del objeto HTTP::Request::Common:
Using perl Syntax Highlighting
my $mech = new WWW::Mechanize(
autocheck => 1 # If set to 1, WWW::Mechanize will produce its
# own error messages.
);
# For more information on how $file works, please check out
# see http://search.cpan.org/perldoc?HTTP::Request::Common#POST
my $file = [
'filename-on-disk.txt', # The file you'd like to upload.
'filename-for-upload.txt', # The filename you'd like to give the web server.
'Content-type' => 'text/plain' # Any other flags you'd like to add go here.
];
$mech->post("http://example.com/upload.cgi", [
'upload' => $file
]);
Coloreado en 0.004 segundos, usando
GeSHi 1.0.8.4
2.- Usando el propio objeto WWW::Mechanize
Using perl Syntax Highlighting
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( $url );
$mech->submit_form(
form_number => 1,
fields => {
image => '/home/mantovani/foo.png',
description => 'this is an example',
}
);
Coloreado en 0.001 segundos, usando
GeSHi 1.0.8.4
Es decir, lo de siempre: dar la ruta completa al fichero.