I need a button that can be fully customised via css to prompt the user to select a file for upload when clicked. Does anyone know how to do this? Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’ll want an input of file type, you can just add the field to your markup:
You can hook into it using css:
There are methods in rails to generate the markup for you, have a look at the
file_fieldmethod http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-file_field orfile_field_tagmethod here: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-file_field_tagMake sure you make your form multipart or you’ll have problems uploading the file using the input.