.. 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.