Created
May 9, 2017 04:53
-
-
Save pixelmord/11ec1cbb0af35b59f615fa5f710de501 to your computer and use it in GitHub Desktop.
This file contains 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
<input id="inp" type='file'> | |
<p id="b64"></p> | |
<img id="img" height="150"> |
This file contains 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
function readFile() { | |
if (this.files && this.files[0]) { | |
var FR= new FileReader(); | |
FR.addEventListener("load", function(e) { | |
document.getElementById("img").src = e.target.result; | |
document.getElementById("b64").innerHTML = e.target.result; | |
}); | |
FR.readAsDataURL( this.files[0] ); | |
} | |
} | |
document.getElementById("inp").addEventListener("change", readFile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment