File upload does not work using:
form.file_upload_with(:name => 'image[1]').file_name = '/tmp/image.jpg'
form.submit
This is an out-of-date example: https://github.com/sparklemotion/mechanize/blob/master/examples/flickr_upload.rb
I tried this on two different sites.
I'm using Mechanize 2.6.0.
Slightly off-topic, but another way to upload files with Mechanize I found useful, particularly if you don't have a HTML form handy, is to just use Mechanize.post
with a File
instance:
a = Mechanize.new
a.post(url, {
"file1" => File.new("/tmp/image.jpg")
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With