Pasting file not work from clipboard on react

700 Views Asked by At

I want to implement image upload by pasting from the clipboard.

so, I tried that get a file object from onPaste

const handlePaste = (e)=>{
   console.log(e.clipboardData);
}
<input onPaste={(e)=>handlePaste(e)} />

In console.log I don't get any data. Here is the SC for reference.

Screeenshot

How to tackle this? Is there any alternative for this so that we could get the image data and display the image using blob ?

1

There are 1 best solutions below

0
On

You can use onPasteCapture

<input onPasteCapture={(e) => {
    console.log(e.clipboardData.files)
}} />