Skip to content

Instantly share code, notes, and snippets.

@SuddenlyHazel
Created June 29, 2021 13:07
Show Gist options
  • Save SuddenlyHazel/bb3474824e029bd776bf9cc448f05933 to your computer and use it in GitHub Desktop.
Save SuddenlyHazel/bb3474824e029bd776bf9cc448f05933 to your computer and use it in GitHub Desktop.
var reader = new FileReader()
var fileByteArray = []
reader.readAsArrayBuffer(file)
reader.onloadend = function (evt) {
if (evt.target.readyState == FileReader.DONE) {
var arrayBuffer = evt.target.result,
array = new Uint8Array(arrayBuffer)
for (var i = 0; i < array.length; i++) {
fileByteArray.push(array[i])
}
console.log("Yay bytes! ", fileByteArray)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment