A Pen by Le Roux Bodenstein on CodePen.
Created
April 8, 2014 14:52
-
-
Save lerouxb/10137085 to your computer and use it in GitHub Desktop.
A Pen by Le Roux Bodenstein.
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
| paste a file here and check the console output |
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
| window.addEventListener("paste", function (event) { | |
| var dataTransfer = event.dataTransfer; | |
| var clipboardData = event.clipboardData | |
| console.log(dataTransfer, "(undefined)"); | |
| console.log(clipboardData.files.length, "(0)"); | |
| var items = clipboardData.items; | |
| console.log(items.length, "(2)"); | |
| var item, file; | |
| for (var i=0; i<items.length; i++) { | |
| item = items[i]; | |
| if (item.kind == 'file') { | |
| file = item.getAsFile(); | |
| console.log(file, "(Blob)"); | |
| console.log(file.name, "(undefined)"); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment