Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

221
Visualizações
Why am I getting a DOMException: "the operation is insecure" when adding a file to a drag&drop dataTransfer?

.. and what can I do about it?

Trying to add files to a drag event I came across a piece of documentation from Adobe showing how to add a file to event.dataTransfer.

I want to be able to generate the files contained in the dataTransfer so I tried this:

document.getElementById("draggable_element").addEventListener('dragstart', e => {
  e.dataTransfer.effectAllowed = "copy";
  e.dataTransfer.setData("application/x-moz-file",
    new File(["hello world"], "data.txt", {
      type: "text/plain",
      lastModified: new Date().getTime(),
    }));
});

(see this jsfiddle)

Unfortunately executing setData gives me a DOMException: the operation is insecure, without further explanation.

Googling and DuckDuckGoing gave me no results related to drag and drop so I have no clue what's going on and what I can do about it.

Is it possible to create files on the fly to append them to a drag&drop events dataTransfer? This answer suggests a way, but the context is totally different.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda