lib/mechanize/form.rb in mechanize-0.6.10 vs lib/mechanize/form.rb in mechanize-0.6.11
- old
+ new
@@ -174,12 +174,13 @@
"#{mime_value_quote(name)}\"\r\n" +
"\r\n#{value}\r\n"
end
def file_to_multipart(file)
+ file_name = file.file_name ? ::File.basename(file.file_name) : ''
body = "Content-Disposition: form-data; name=\"" +
"#{mime_value_quote(file.name)}\"; " +
- "filename=\"#{mime_value_quote(file.file_name || '')}\"\r\n" +
+ "filename=\"#{mime_value_quote(file_name)}\"\r\n" +
"Content-Transfer-Encoding: binary\r\n"
if file.file_data.nil? and ! file.file_name.nil?
file.file_data = ::File.open(file.file_name, "rb") { |f| f.read }
file.mime_type = WEBrick::HTTPUtils.mime_type(file.file_name,