Drag and drop files using only JavaScript

1 · Amit Merchant · May 18, 2020, 12:25 p.m.
You’ve probably seen or have used this feature where you can upload files by dropping the selected files into the specific area. For example, how Gmail handles this while drafting emails. You can implement this using some libraries and be done with it… but what if I tell you could build this using only JavaScript? Well, it’s fairly easy to do so. You first need an element onto which files will get dropped. We can call it “dropzone”. <div id="dropbox"></div> Now, you can attach some events liste...