From: David Heinemeier Hansson Date: 2003-10-26T23:49:19+09:00 Subject: Problems mixing regular form fields with file uploads I'm trying to build a form that includes both regular form fields, such as text inputs and checkboxes, along with file uploading. It seems, though, that all the fields are treated like a File when a file input is used. I've tried to narrow it down with this script: require 'CGI' cgi = CGI.new if cgi.params.length == 0 print "
" print "" print "
" else $stderr << cgi.params['title'].first $stderr << cgi.params['logo'].first.original_filename end Entering "A picture" in the title input and choosing a file called "123.jpg" would add the following to the log: "A picture123.jpg". Instead I get "#123.jpg". Entering "A picture" in the title input and not choosing a file produces: ## I'm baffled. Why is the title input treated first as a file and since as a StringIO? I reckon it has something to do with the enctype, but I can't seem to come up with a solution. How would one go about extracting regular form data alongside file handling? Note, I'm using mod_ruby 1.1.1, Apache 1.3.x, and Ruby 1.8.0 on OS X 10.3. // David