mechanize:Mechanize::Form#file_uploads_with, #file_uploads
以下のような HTML で
<html> <head> <title>form test</title> </head> <body> <form method="get" action="cgi/foo00.cgi" name="form1"> <input type="file" name="File" /> </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb743a604 ... >> page = agent.get('http://127.0.0.1:8080/test12_form.html') => #<Mechanize::Page {url #<URI::HTTP:0xb7436d4c URL:http://127.0.0.1:8080/test12_form.html>} {meta} {title "form test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads #<Mechanize::Form::FileUpload:0xb742e368 @file_data=nil, @file_name=nil, @name="File", @node= #(Element:0x..fdba17236 { name = "input", attributes = [ #(Attr:0x..fdba154e0 { name = "type", value = "file" }), #(Attr:0x..fdba154d6 { name = "name", value = "File" })] }), @value=nil>} {buttons}>}> >> f = page.form('form1') => #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads #<Mechanize::Form::FileUpload:0xb742e368 @file_data=nil, @file_name=nil, @name="File", @node= #(Element:0x..fdba17236 { name = "input", attributes = [ #(Attr:0x..fdba154e0 { name = "type", value = "file" }), #(Attr:0x..fdba154d6 { name = "name", value = "File" })] }), @value=nil>} {buttons}> >> f.file_uploads_with => [#<Mechanize::Form::FileUpload:0xb742e368 @file_name=nil, @file_data=nil, @name="File", @value=nil, @node=#<Nokogiri::XML::Element:0x..fdba17236 name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba154e0 name="type" value="file">, #<Nokogiri::XML::Attr:0x..fdba154d6 name="name" value="File">]>>] >> f.file_uploads => [#<Mechanize::Form::FileUpload:0xb742e368 @file_name=nil, @file_data=nil, @name="File", @value=nil, @node=#<Nokogiri::XML::Element:0x..fdba17236 name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba154e0 name="type" value="file">, #<Nokogiri::XML::Attr:0x..fdba154d6 name="name" value="File">]>>]