Answers for "upload on paste js"

0

upload on paste js

document.addEventListener('paste', function(e){
  console.warn(e.clipboardData.items.length);
  for (var i = 0; i < e.clipboardData.items.length; i++) {
    var item = e.clipboardData.items[i];
    console.log('Item: ' + item.type);
    if (item.type.indexOf('image') != -1) {
      //item.
      console.log(item.getAsFile());
    } else {
      // ignore not images
      console.log('Discarding not image paste data', item);
    }
  }
});
Posted by: Guest on July-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language