Skip to content

Instantly share code, notes, and snippets.

@almond-bongbong
Last active August 17, 2018 04:30
Show Gist options
  • Save almond-bongbong/39bd537f0bd277ce01a9af27acc5a31e to your computer and use it in GitHub Desktop.
Save almond-bongbong/39bd537f0bd277ce01a9af27acc5a31e to your computer and use it in GitHub Desktop.
imageToByteArray(e) {
const that = this;
const file = e.target.files[0];
const reader = new FileReader();
reader.onloadend = function() {
// with react
that.setState({img: reader.result});
};
reader.readAsDataURL(file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment