Using clipboardData.getData for image files
I'm trying to write a jquery script that gets the data out of an image file that's being copied and pasted and then turns it into a DataURL. The getData option here is returning nothing for me when I paste in a file (ex: myfile.jpg). It doesn't seem to matter whether I do this as getData("text") or getData something else.
Alternatively, if I can't get the contents of a file this way, is there a way to convert the jQuery event object into a regular Javascript event object. I can use e.clipboardData.items[0].getAsFile() if this were a regular JS event. I don't see an equivalent in jQuery.
- $('iframe').each(function () {
- $(this).contents().find('body').on('paste', function (e) {
-
- console.log("paste captured");
- if ( (myevent.clipboardData.types[0].indexOf("file") != -1) && (myevent.clipboardData.files[0].type.indexOf("image") != -1) ) {
-
- e.preventDefault();
-
-
-
- var mimetype = myevent.clipboardData.files[0].type;
-
- var filename = myevent.clipboardData.files[0].name;
-
- var blob = myevent.clipboardData.getData("Text");
-
- console.log("blob: " + blob + " -- " + blob.length);
-
- }
- });
- });