Last active
August 29, 2015 14:19
-
-
Save morshedalam/68c6c70c3aadb44c46d8 to your computer and use it in GitHub Desktop.
Custom file field
This file contains hidden or 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
.custom-file-upload { | |
width: 100%; | |
position: relative; | |
padding: 0px; | |
} | |
.custom-file-upload:before { | |
content: 'Browse'; | |
position: absolute; | |
right: 0px; | |
top: 0px; | |
cursor: pointer; | |
background: #000 url(arrow.png) no-repeat 70px 7px; | |
height: 40px; | |
padding: 9px 45px 9px 10px; | |
} | |
*>.custom-file-upload input.fake-file { | |
z-index: 998; | |
text-wrap: none; | |
} | |
*>.custom-file-upload input[type=file]{ | |
position: absolute; | |
top: 0; | |
left: -500px; | |
margin: 0; | |
width: 1000%; | |
background: transparent; | |
z-index: 999; | |
margin: 0; | |
text-wrap: none; | |
opacity: 0; | |
} |
This file contains hidden or 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
<div class="custom-file-upload"> | |
<input type="text" class="fake-file" placeholder="Select MP3" name="mp3"> | |
<input id="track_track" name="track[track]" placeholder="Browse" required="required" type="file"> | |
</div> |
This file contains hidden or 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
$('body').on("change", ".custom-file-upload input:file", function () { | |
$(this).closest('.custom-file-upload').find('.fake-file').val($(this).val().split('\\').pop()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment