0Pricing
JavaScript Academy · Lesson

Dragging Files into the Page

Handle files dropped from the desktop.

Files from the Desktop

Beyond moving elements, the Drag and Drop API lets users drag files from their operating system into your page — the foundation of upload drop zones.

Accepting File Drops

The setup mirrors element drops: prevent default on dragover and drop. The difference is reading files instead of getData.

dropzone.addEventListener("dragover", (e) => e.preventDefault());

All lessons in this course

  1. Making Elements Draggable
  2. Drop Targets and dataTransfer
  3. Visual Feedback During Drag
  4. Dragging Files into the Page
← Back to JavaScript Academy