Reputation: 47
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.
How to tackle this? Is there any alternative for this so that we could get the image data and display the image using blob ?
Upvotes: 0
Views: 935
Reputation: 458
You can use onPasteCapture
<input onPasteCapture={(e) => {
console.log(e.clipboardData.files)
}} />
Upvotes: 1