Skip to content

Instantly share code, notes, and snippets.

@Nikeshsuwal
Last active December 22, 2015 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikeshsuwal/4a12ae52250a83b0a268 to your computer and use it in GitHub Desktop.
Save Nikeshsuwal/4a12ae52250a83b0a268 to your computer and use it in GitHub Desktop.
Custom style to upload file
form
.form-group.image-upload
label for="society_image"
span
| Upload Society Picture
i.fa.fa-cloud-upload
.file_name
= f.file_field :image, placeholder: "Upload Society Picture",class: 'form-control input-lg inputfile'
.image-upload input{
display: none;
}
.image-upload label{
cursor: pointer
}
//To show uploaded file name
$('#society_image').change(function() {
var filename, lastIndex;
filename = this.value;
lastIndex = filename.lastIndexOf('\\');
if (lastIndex >= 0) {
filename = filename.substring(lastIndex + 1);
}
return $('.file_name').html(filename);
});
@Nikeshsuwal
Copy link
Author

There label for "society_image" must same to input file id "society_image"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment