Mechanize Form File Upload

Hi all,

I’m trying to upload a file to a Form in this way. My Question is, how
to get the imagefile posted correctly.

def uploadpicture(username, password, imagepath)
agent = Mechanize.new
agent.post(“http://www.somesite.com/”,
{ ‘function’ => ‘picture2’,
‘username’ => username,
‘password’ => password,
‘pict’ => ???,
‘pict_to’ => 0,
‘pict_type’ => 0,
‘submit’ => ‘Send’ }) { |page| return page }
end

Thanks and Regards,

T.

            'pict' => ????????,

File.binread(‘pic.jpg’) ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs