Created
February 28, 2020 19:09
-
-
Save zuzannamj/35953072b99a35434289f65876e55bed 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
document.getElementById('button').addEventListener('click', function() { | |
var files = document.getElementById('file').files; | |
if (files.length > 0) { | |
getBase64(files[0]); | |
} | |
}); | |
function getBase64(file) { | |
var reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = function () { | |
console.log(reader.result); | |
}; | |
reader.onerror = function (error) { | |
console.log('Error: ', error); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment