Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created January 17, 2014 22:05
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 cmilfont/8482600 to your computer and use it in GitHub Desktop.
Save cmilfont/8482600 to your computer and use it in GitHub Desktop.
document.onpaste = function(event){
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
var blob = items[0].getAsFile();
var reader = new FileReader();
reader.onload = function(event){
console.log(event.target.result)}; // data url!
reader.readAsDataURL(blob);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment