Using clipboardData.getData for image files

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.


  1.  $('iframe').each(function () {
  2.               $(this).contents().find('body').on('paste', function (e) {

  3. console.log("paste captured");
  4. if ( (myevent.clipboardData.types[0].indexOf("file") != -1) && (myevent.clipboardData.files[0].type.indexOf("image") != -1) ) {

  5. e.preventDefault();

  6. var mimetype = myevent.clipboardData.files[0].type;

  7. var filename = myevent.clipboardData.files[0].name;

  8. var blob = myevent.clipboardData.getData("Text");

  9. console.log("blob: " + blob + " -- " + blob.length);

  10. }
  11.       });
  12.     });