When HTML is copied to the clipboard, most applications also copy a plain text version. The HTML version is used when pasting into applications that support rich text.
$imageDataUri = Clipboard::image();if ($imageDataUri) { // Save or process the image $imageData = base64_decode(explode(',', $imageDataUri)[1]); file_put_contents('clipboard-image.png', $imageData);}
The Clipboard class supports Laravel’s Conditionable trait:
Clipboard::when($shouldCopyHtml, function ($clipboard) { $clipboard->html('<h1>Formatted</h1>');}, function ($clipboard) { $clipboard->text('Plain text');});
Reading from the clipboard requires appropriate permissions on some operating systems. Users may need to grant clipboard access permissions on first use.