Enable copy and paste files in dropzone.js

后端 未结 3 1275
庸人自扰
庸人自扰 2020-12-14 21:13

I am using dropzone.js. I want to implement the \"Copy & Paste\" feature in it.

What I tried is:

Inside dropzone.js:<

3条回答
  •  情书的邮戳
    2020-12-14 22:10

    var myDropzone = new Dropzone(".dropzone", { });
    
    document.onpaste = function(event){
      var items = (event.clipboardData || event.originalEvent.clipboardData).items;
      for (index in items) {
        var item = items[index];
        if (item.kind === 'file') {
          // adds the file to your dropzone instance
          myDropzone.addFile(item.getAsFile())
        }
      }
    }
    

    Just add this code. Do not declare URL because URL also declared in PHP or coding file, paste this code in view file (HTML, PHP, etc).

提交回复
热议问题