0

I want elements of a webpage dragged&dropped out of the browser window contain arbitrary file objects, which can be dropped to e.g. a file browser.

Having the event.dataTransfer.files contain text and being able to drop it in a text editor works for me by adding the text via setData():

e.dataTransfer.setData("text/plain", "hello world);

However adding files doesn't work this way. I can call e.dataTransfer.items.add() with an file object without errors but with no effect in the external window neither.

Replacing e.dataTransfer.setData() with e.dataTransfer.items.add() (as the documentation suggests) also doesn't work for the text, so I guess, I'm missing something.

What's the equivalent to dataTransfer.setData("text/plain", "hello world); for files then?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.