Created
November 12, 2020 01:07
-
-
Save davidicus/9c0c0d433d21b8014f999b1763405e72 to your computer and use it in GitHub Desktop.
Drag and drop file upload and conversion to data URL
This file contains hidden or 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
const handleOnChange = (e, callback) => { | |
console.log('onChanged'); | |
const fReader = new FileReader(); | |
fReader.readAsDataURL( | |
e.type === 'drop' ? e.dataTransfer.files[0] : e.target.files[0] | |
); | |
fReader.onloadend = (event) => { | |
callback(event.target.result); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment