Rails, uploading a file using only file_field -
i need upload file in rails without gems, decided use
<%= file_field 'upload', 'datafile' %></p>
without form , etc. file_field , in controller tried catch
name = params[:upload][:datafile].original_filename
it shows me error:
undefined method `original_filename' "me.jpg":string
my params:
"upload"=>{"datafile"=>"me.jpg"}
it seems cannot use file_field alone without form, can i? or should alway include form? if yes, possible without using form?
please verify have added multipart: true option in form_tag or not.
syntax:-
<%= form_tag '/upload', multipart: true %> <label for="file">file upload</label> <%= file_field_tag "file" %> <%= submit_tag %> <% end %>
Comments
Post a Comment