Skip to content

Instantly share code, notes, and snippets.

@xem
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xem/f2a98e4df3ae3076b8fd to your computer and use it in GitHub Desktop.
Save xem/f2a98e4df3ae3076b8fd to your computer and use it in GitHub Desktop.
log the binary content of files dropped in the browser. also works for multiple files.
<html ondrop="f(event);return!1"ondragover=return!1>
<script>
f=function(e){
d=e.dataTransfer.files;
for(i=0;i<d.length;i++){
with(new FileReader){
readAsArrayBuffer(d[i]);
onload=function(){console.log(new Uint8Array(result))};
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment