ruby on rails - How to limit only images to be uploaded through file_field tag? -


<%= form_for @model_name, :url => {:controller => 'controller_name', :action => 'index'},:html => {:multipart => true},:validate => true |f| %>  <%= file_field 'upload', 'datafile'%>  <% end %> 

i have form. want upload images through upload. how this?

you can use paperclip gem manage file attachments. has validates_attachment validator helpful.

validates_attachment :avatar, :presence => true,   :content_type => { :content_type => "image/jpg" },   :size => { :in => 0..10.kilobytes } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -