How do I set up Dropzone JS to receive an image just by typing CTRL+ V, so that it accepts text and images together?

Asked

Viewed 65 times

0

I was watching the outlook and the email edit field gets images via CTRL+V, searching found that this would be a Dropzone component. I would like to know how to set up.

Below the example of outlook.

inserir a descrição da imagem aqui

1 answer

0

    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())
        }
      }
    }

Places the above code inside the init function

Browser other questions tagged

You are not signed in. Login or sign up in order to post.