I can’t find a good example of how to do it properly, the ones I found do not work for me .. I am trying to submit a form using perl mechanize, where the form has an image file, the form below is actually a way. by which I am trying to access this API for the website from which I have an account, and using POST is apparently 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 tried this, but its not loading the image file, it seems .. any advice is welcome. (I just left parts of the script, but I can submit other forms using this method, and not the 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'
);
$mech->submit();