I can't seem to find a good example of how to do this properly, the ones I have found aren't working for me.. I am trying to submit a form using perl mechanize, where the form has an image file, the form is as below, its actually a way I am trying to access this API for a website from which I have an account and using POST seems to be the easiest way to use their API:
<HTML>
<BODY>
<form
method="post"
name="image_upload"
action="http://example-website.com"
enctype="multipart/form-data">
<input type="hidden" name="field1" value="">
<input type="text" name="username" value="">
<input type="text" name="password" value="">
<input type="file" name="pict">
<input type="text" name="field2" value="0">
<input type="text" name="field3" value="0">
<input type="submit" value="Send">
</form>
</BODY>
</HTML>
I have tried this, but its not uploading the image file, it seems.. any advice is appreciated. (I left out parts of the script for simplicity, but I am able to submit other forms using this method, just not ones that require a file upload)
fill form field:$mech->form_name('image_upload');
$mech->set_fields( field1 => '',
username => $username,
password => $password,
pict => '/home/user1/Desktop/pic.jpg',
field2 => '0',
field3 => '0'
);
#### submit form
$mech->submit();