Can you tell me how do i create a page that allows me to have a facility
by which the user can upload a file to the defined folder
pls provide the code for controller,model and view
thanks
dhaval
--
Posted via http://www.ruby-forum.com/.
Controller action:
def upload
File.open
"#{RAILS_ROOT}/uploads/#{params[:file].original_filename}", 'wb' do |f|
f.write(params[:file].read)
end
redirect_to :action => 'index'
end
View:
<% form_tag({:action => 'upload'}, {:multipart => true}) do %>
Upload a file:
<%= file_field_tag 'file' %>
<%= submit_tag 'Submit' %>
<% end %>