There is a problem with JavaScript reading pictures from the pasteboard.

now I want to get the picture for some processing before the user pastes the picture into the text box, so I intercept the paste event

$(".w-e-text").on("paste",function(e){
    console.log(e)
});

then I copy a picture locally, but the object from the browser print shows the clipboard like this:

clipboard.png

is there a big god who can tell me how to get the pictures from the clipboard in JavaScript? now it"s a function for Chrome browsers

Apr.07,2021

var files = e.clipboardData && e.clipboardData.items;

// 
var file = files[0];

if (file && file.size > 0 && /image\/\w+/i.test(file.type)) {
   // ,  0
}
Menu