Last active
December 22, 2015 05:48
-
-
Save Nikeshsuwal/4a12ae52250a83b0a268 to your computer and use it in GitHub Desktop.
Custom style to upload file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.image-upload input{ | |
display: none; | |
} | |
.image-upload label{ | |
cursor: pointer | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There label for "society_image" must same to input file id "society_image"