1

I notice that Discord can detect if you drop a folder without sending any validation request to a server, all in the client. How can I do that?

When a file is submitted from an <input type="file"> then there is no problem, because it can't select folders, but on a drag-and-drop system you can drop anything and I'm looking for a way to detect folders because it's weird how if you drop a folder, let's say folderExample you get a File object with the property type="", BUT when you drop the same folder with a name like folderExample.jpg now the type is "image/jpeg"!!!

There is how I'm handling the file dropping, hope some can help

const handleDrop = (e) => {
    e.preventDefault();
    e.stopPropagation();
  
    const {files} = e.dataTransfer;
    console.log('Dropped files:', files)
  };

0 Answers0