As far as I can read from the WWW::Mechanize documentation, you can do the following to submit a file from a string:
$mech->submit_form(
fields => {
'UploadedFile' => [[ undef, 'test2.txt', Content => $content ], 1],
}
);
This should submit a file with name text2.txt
, containing the text in $content
(in this case, 'The file is a lie.'
).
The request failed with an internal server error, however, so I examined the request that was sent, and found this:
--xYzZY
Content-Disposition: form-data; name="UploadedFile"; filename="ARRAY(0x9567570)"
The file is a lie.
--xYzZY
That is clearly not the filename I specified, so I wonder: Am I doing something wrong, or is the module bugged?
filename="ARRAY(0x1f124d8)"
too, dumping$mech->res
(WWW::Mechanize
1.66 ). – Furywith_fields
gave the same result asfields
. – Ascitesfields => {'UploadedFile' => [ undef, 'test2.txt', Content => $content ], upload_field => 1 }
, where upload_field is the name of the form submission field, work correctly? – Gregorioupload_field
? – Ascites