Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
How to let a drag&drop event transfer arbitrary files to external application?

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);

This is an example demonstrating drag&drop to an external application (with text only): https://jsfiddle.net/vg129k4z/

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.

This is the modification of the example above adding a file instead of a text: https://jsfiddle.net/3kgw7ba9/

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

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda