Reputation: 237
Hi I am using paperclip in my rails application to upload files. I would like to know how to pas the original file path in a form_tag. Or get the original file path in the controller, to be specific Thanks
<%= form_tag upload_categories_path, :method => :get do %>
<td><%= file_field_tag :file_name %></td>
<td><%= submit_tag t('submit') %></td>
<% end %>
Upvotes: 0
Views: 127
Reputation: 467
Modify your form tag :
<%= form_tag upload_categories_path, :html => { :multipart => true }, :method => :get do %>
<td><%= file_field_tag :file_name %></td>
<td><%= submit_tag t('submit') %></td>
<% end %>
In your post action, you can get the file path by:
params[:file_name].path
Upvotes: 1
Reputation: 284
Please make sure you have added :html => { :multipart => true } in your Form. like
<%= form_tag upload_categories_path, :method => :get, :html => { :multipart => true } do %>
<td><%= file_field_tag :file_name %></td>
<td><%= submit_tag t('submit') %></td>
<% end %>
Upvotes: 0