diff options
Diffstat (limited to 'public/js/upload.js')
| -rw-r--r-- | public/js/upload.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/public/js/upload.js b/public/js/upload.js index ba67d15..b620248 100644 --- a/public/js/upload.js +++ b/public/js/upload.js @@ -105,6 +105,7 @@ upload.prepareDropzone = function(){ }, init: function() { this.on('addedfile', function(file) { + myDropzone = this; document.getElementById('uploads').style.display = 'block'; }); } @@ -139,6 +140,22 @@ upload.prepareDropzone = function(){ } +//Handle image paste event +window.addEventListener('paste', function(event) { + var items = (event.clipboardData || event.originalEvent.clipboardData).items; + for (index in items) { + var item = items[index]; + if (item.kind === 'file') { + var blob = item.getAsFile(); + console.log(blob.type); + var file = new File([blob], "pasted-image."+blob.type.match(/(?:[^\/]*\/)([^;]*)/)[1]); + file.type = blob.type; + console.log(file); + myDropzone.addFile(file); + } + } +}); + window.onload = function () { upload.checkIfPublic(); };
\ No newline at end of file |