Skip to content

Instantly share code, notes, and snippets.

@r4fx
Last active August 29, 2015 14:07
Show Gist options
  • Save r4fx/129e320ca15d4a36e55a to your computer and use it in GitHub Desktop.
Save r4fx/129e320ca15d4a36e55a to your computer and use it in GitHub Desktop.
Custom input file
$(function () {
$('_btnBrowse').click(function (e) {
e.preventDefault();
$('#inputUpload').click();
});
$('#inputUpload').change(function () {
var filename = $('input[type=file]').val().split('\\').pop();
var setContent = $('.inputFile').html(filename);
});
});
<form>
<span class="inputFile">nie wybrano pliku...</span>
<input type="file" name="file" id="inputUpload">
</form>
<span class="_btnBrowse">Przeglądaj</span>
.inputFile{
border: 1px solid #ccc;
padding: 5px 20px;
display: inline-block;
background-color: #eee;
cursor: default;
}
#inputUpload{
opacity: 0;
visibility: hidden;
width: 5px;
position: absolute;
right: 0;
top: 0;
}
.btnBrowse{
display:inline-block;
background-color: #ca7fd1;
color: #fff;
padding: 5px 10px;
margin-top: 10px;
cursor: pointer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment