I''m trying to do the classic file upload to a directory in my file
system (public/drawings). I have the following:
In the view:
<%= file_field ( "drawing", "drawingfile" ) %>
In the controller, in addition to the usual <model>.save, I have
@drawing.save_drawing(params[:drawing][:drawingfile])
In the model, I have
def save_drawing(inputfile)
if inputfile.original_filename
File.open("#{RAILS_ROOT}/public/drawings/#{inputfile.original_filename}",
"wb") {
|f| f.write(inputfile.read) }
end
inputfile
end
The save_drawing routine is almost verbatim from the HowToUploadAFile
document. It *IS* creating a file in the right location in the file
system, but no data is being written to it (e.g. a zero length file).
What am I missing?
Thanks in advance
---Michael
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---