Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Perl Mechanize, how to submit a form with a file (image)?

Avatar of rickdca
rickdca asked on
3 Comments1 Solution1235 ViewsLast Modified:
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:


 <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">


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)


$mech->set_fields( field1 => '',
username => $username,
password => $password,
pict => '/home/user1/Desktop/pic.jpg',
field2 => '0',
field3 => '0'

#### submit form
Avatar of Tobias
TobiasFlag of Switzerland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers