Clipboard Paste Upload
Paste images or files from the clipboard (Ctrl+V / Cmd+V). Great for screenshots.
(function() {
new MultipleUpload('#demo', {
uploadUrl: '/api/upload',
multiple: true,
paste: true,
showThumbnails: true,
onPaste: function(files) {
console.log('Pasted', files.length, 'file(s)');
}
});
})();Try it: Copy an image, then press Ctrl+V / Cmd+V anywhere on this page.
Ctrl+V as a first-class route
paste defaults to true, so clipboard uploads are already on. It matters more than it sounds: a screenshot lives on the clipboard, and without paste the user has to save it to disk, find it in a file dialog, and delete it afterwards — three steps to avoid one.
Scoping where paste is captured
pasteTarget defaults to null, which listens at the document level. Point it at an element to scope the listener there instead, which is what you want when the page has more than one place a paste could sensibly land — a comment box beside an attachment area, for instance.
A pasted image has no file name, so the component names it from the timestamp. If your server expects meaningful names, rename on arrival rather than relying on the client's.