ruby on rails 4 - Validation for file type -


am using carrierwave gem upload file.

i need validate file while uploading ,it should accept pdf,jpg , png.

is there solution clientside validation.

the html input element has accept attribute can use filter file type. http://www.w3schools.com/tags/att_input_accept.asp

you can validate file extension using http://jqueryvalidation.org/extension-method/

this not prevent malicious user uploading different file type intended, should still validate after uploading using https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/processing/mime_types.rb


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -