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
Post a Comment