Safari and Firefox multipart form submission differences
I just stumbled on a strange difference between submitting multiparts forms via Firefox and Safari. When a file isn’t selected and the form is submitted, Firefox sends the variable name with an empty string as the value. Safari doesn’t send the variable at all. This caused an unexpected problem in Rails when I was checking if the variable was an empty string or not. I honest would prefer to check if the variable is nil or not and if its not nil I’d know the file was sent. I checked for an empty string because Firefox sends the variable. Not my code has to also check if its nil and if not then check if the filename is not an empty string. Lame.

July 30th, 2007 at 3:08 am
I think I might be wrong about this whole thing now. Both browsers are sending the file variable over. For some reason in Rails params[:file][:name].original_filename = ” when Firefox submit the form and params[:file][:name] = ” when Safari submits it.
That tells me Safari isn’t sending over the form as multipart when a file isn’t selected. Lame Safari. I specified it in the form tag. Do what I say already!