how to paste image on upload 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);
}
}
});
Are there any code examples left?
New code examples in category Javascript