Skip to content

Instantly share code, notes, and snippets.

@h26k2
Created July 22, 2019 12:32
Show Gist options
  • Save h26k2/c7600a01139395717ae4e5ecf17f0399 to your computer and use it in GitHub Desktop.
Save h26k2/c7600a01139395717ae4e5ecf17f0399 to your computer and use it in GitHub Desktop.
Displays a picture LOCALLY when user uploads
/**************************************************************
* Displaying Picture when user uploads it (from the localhost)
***************************************************************/
let tempProfilePicContainer = document.getElementById("reg--profile--pic");
let reader = new FileReader();
function showImage(that){
reader.onload = function(event){
tempProfilePicContainer.setAttribute("style","background-image:url('"+reader.result+"')");
}
reader.readAsDataURL(event.target.files[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment