Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!