Skip to content

Instantly share code, notes, and snippets.

@valentinoPereira
Created April 2, 2018 05:53
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 valentinoPereira/87338ff1e5b3329fcd8d9304b668ad8d to your computer and use it in GitHub Desktop.
Save valentinoPereira/87338ff1e5b3329fcd8d9304b668ad8d to your computer and use it in GitHub Desktop.
// Banner Listeners
$(document).on('change', '#profile-banner-file-input', function() {
var input = $(this);
if (input[0].files && input[0].files.length > 0) {
var fileObject = input[0].files[0];
if(fileObject.size<=3*1024*1024) {
var reader = new FileReader();
reader.onload = function (e) {
$('#uploaded-banner-preView').attr('src', e.target.result);
$('#uploaded-banner-preview-fullscreen').attr('href', e.target.result);
$('#uploaded-banner-name').text(fileObject.name);
$('#uploaded-banner-size').text(formatBytes(fileObject.size));
$('#uploaded-banner-file-type').text(fileObject.type);
}
reader.readAsDataURL(input[0].files[0]);
$('.uploaded-banner').show();
} else {
alert("JPG images of maximum 2MB");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment