Skip to content

Instantly share code, notes, and snippets.

@NickDeckerDevs
Created October 4, 2016 16:07
Show Gist options
  • Save NickDeckerDevs/4e3b97d3e6d9a1f31fa5471153e7ec8a to your computer and use it in GitHub Desktop.
Save NickDeckerDevs/4e3b97d3e6d9a1f31fa5471153e7ec8a to your computer and use it in GitHub Desktop.
How to append the name of a file if you are replacing the normal functionality of a file upload button
$(window).load(function() {
$('input[type=file]').on('change', function() {
var filename = $(this).val().split('\\');
if($('#filename-information').length > 0) {
$('#filename-information').html('Selected File: '+filename[filename.length - 1]);
} else {
$(this).parent().append('<div id="filename-information">Selected File: '+filename[filename.length - 1]+'</div>');
}
});
});
@NickDeckerDevs
Copy link
Author

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