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

122
Views
Is there a way to add directory to DataTransferItemList?

I'm trying to simulate drag and drop event with a directory.

What I excatly want to do is convert canvas into file, put it into directory and dispatch drag event.

All of it is done by extension that works on specyfic site. I can drop there directory "img" with "icon.png" manually from file explorer. Drag data is being handled on that site by webkitGetAsEntry().
Works similar to example on this site.

Here's how I can simulate dropping just 1 file:

const canvas = document.createElement("canvas");
const ctx = canvas.getContext('2d');
ctx.fillStyle = "white";
ctx.fillRect(0, 0, 50, 50);

canvas.toBlob(function(blob) {
    let dataTransfer = new DataTransfer();
    let file = new File([blob], "icon.png"); 
    dataTransfer.items.add(file);
    document.querySelector(".drop-zone").dispatchEvent(new DragEvent('drop', {dataTransfer}));
});

But how to make webkitGetAsEntry see dropped data as directory? For example /img/icon.png

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!