Dropzone.js: Versatile JavaScript Drag & Drop File Uploader

Category: Form , Javascript , Recommended | September 12, 2026
Authorenyo
Last UpdateSeptember 12, 2026
LicenseMIT
Views18,037 views
Dropzone.js: Versatile JavaScript Drag & Drop File Uploader

Dropzone.js is a JavaScript file upload library that turns an HTML element into a drag-and-drop upload area.

File selection, previews, progress tracking, queue control, validation, image resizing, and chunked transfers run in the browser.

Dropzone sends files to an upload endpoint, and your server receives, validates, and stores them.

Features

  • Drag-and-drop and click-to-select file input.
  • Multiple-file queues with upload progress.
  • Image thumbnails and browser-side image resizing.
  • File type, file size, and file-count validation.
  • Chunked uploads with retry controls.
  • Manual queue processing and upload cancellation.
  • Custom preview markup and event-driven UI behavior.
  • Raw binary request bodies for Amazon S3 multipart upload workflows.

Use Cases

  • Profile and media forms with image previews before upload.
  • CMS asset screens with multi-file queues and progress states.
  • Large-file uploads split across smaller HTTP requests.
  • Application forms with browser-side file type and size checks.

How To Use Dropzone.js

Install with npm

Install Dropzone from npm.

npm install dropzone

Import the Dropzone export in your JavaScript entry file. Load the package dropzone.css through your CSS pipeline when you want the default Dropzone theme.

import { Dropzone } from "dropzone";
const uploader = new Dropzone("#upload-area", {
  url: "/api/uploads"
});

Create the upload element before this JavaScript runs.

<div id="upload-area"></div>

Use the standalone browser build

Your browser-first projects can load the version 6 standalone files from a CDN.

<link rel="stylesheet" href="https://unpkg.com/dropzone@6/dist/dropzone.css">
<script src="https://unpkg.com/dropzone@6/dist/dropzone-min.js"></script>
<div id="browser-uploader"></div>
<script>
const uploader = new Dropzone("#browser-uploader", {
  url: "/api/uploads"
});
</script>

Configure file type, size, and file count

Set file filters in the Dropzone configuration object. maxFilesize uses MiB, while acceptedFiles accepts MIME types and file extensions.

const uploader = new Dropzone("#document-uploader", {
  url: "/api/documents",
  acceptedFiles: "image/*,application/pdf,.docx",
  maxFilesize: 12,
  maxFiles: 5,
  addRemoveLinks: true
});

Start the upload queue from a button

Set autoProcessQueue to false when files should wait for another form action. Call processQueue() when the upload can start.

<div id="review-uploader"></div>
<button type="button" id="send-files">Upload selected files</button>
const uploader = new Dropzone("#review-uploader", {
  url: "/api/review-files",
  autoProcessQueue: false,
  maxFiles: 4
});
document.querySelector("#send-files").addEventListener("click", function () {
  uploader.processQueue();
});

Upload large files in chunks

Chunking sends one file through multiple requests. Your backend must save the parts and assemble the completed file.

const uploader = new Dropzone("#archive-uploader", {
  url: "/api/archive-parts",
  chunking: true,
  chunkSize: 2 * 1024 * 1024,
  retryChunks: true,
  retryChunksLimit: 3
});

Send extra request data and run custom validation

Use params for extra request fields and accept for custom file checks.

const uploader = new Dropzone("#contract-uploader", {
  url: "/api/contracts",
  params: {
    source: "contract-form"
  },
  accept: function (file, done) {
    if (file.size === 0) {
      done("Empty files are not accepted.");
      return;
    }
    done();
  }
});

Use declarative discovery in Dropzone 6

Dropzone no longer scans .dropzone elements automatically. Configure the form through Dropzone.options, then call Dropzone.discover() after the form exists.

<form action="/api/photos" class="dropzone" id="photo-dropzone"></form>
<script>
Dropzone.options.photoDropzone = {
  acceptedFiles: "image/*",
  maxFilesize: 8
};
Dropzone.discover();
</script>

Dropzone Configuration Options

Request and Upload Options

OptionDescription
urlUpload URL. Default: null. A URL is required when the element is not a form or the form has no action.
methodHTTP method as a string or function. Default: post.
withCredentialsSets XMLHttpRequest.withCredentials. Default: false.
timeoutXHR timeout in milliseconds. Default: null. null or 0 disables the timeout.
parallelUploadsMaximum number of files processed in parallel. Default: 2.
uploadMultipleSends multiple files in one request. Default: false. It cannot be used with chunking or binaryBody.
paramNameFile field name or a function that returns a field name. Default: file.
headersObject containing additional request headers. Default: null.
defaultHeadersAdds Dropzone’s default Accept, Cache-Control, and X-Requested-With headers. Default: true.
binaryBodySends the file as the raw request body. Default: false. It ignores params and cannot be used with uploadMultiple.

Chunked Upload Options

OptionDescription
chunkingSplits a file across multiple requests. Default: false. It cannot be used with uploadMultiple.
forceChunkingUses the chunking workflow for every file when chunking is active. Default: false.
chunkSizeChunk size in bytes. Default: 2 * 1024 * 1024.
parallelChunkUploadsUploads chunks from one file concurrently. Default: false.
retryChunksRetries a failed chunk. Default: false.
retryChunksLimitMaximum retry count for a failed chunk. Default: 3.

File Validation and Queue Options

OptionDescription
maxFilesizeMaximum accepted file size in MiB. Default: 256.
maxFilesMaximum number of accepted files. Default: null.
acceptedFilesComma-delimited MIME types or file extensions used by the built-in acceptance check. Default: null.
acceptedMimeTypesDeprecated alias for acceptedFiles. Default: null.
ignoreHiddenFilesIgnores hidden files found inside dropped directories. Default: true.
autoProcessQueueStarts queue processing automatically after files enter the queue. Default: true.
autoQueueAdds accepted files to the queue automatically. Default: true.
clickableEnables click-to-select or assigns one or more clickable elements. Default: true.
captureSets the hidden file input’s capture mode, such as camera, microphone, or camcorder. Default: null.

Thumbnail and Image Resize Options

OptionDescription
createImageThumbnailsGenerates thumbnails for accepted image files. Default: true.
maxThumbnailFilesizeMaximum image size in MB for thumbnail generation. Default: 10.
thumbnailWidthThumbnail width. Default: 120.
thumbnailHeightThumbnail height. Default: 120.
thumbnailMethodThumbnail scaling mode. Accepted values: crop or contain. Default: crop.
resizeWidthWidth used to resize images before upload. Default: null.
resizeHeightHeight used to resize images before upload. Default: null.
resizeMimeTypeMIME type for the resized upload image. Default: null, which keeps the source type.
resizeQualityQuality passed to canvas image encoding. Default: 0.8.
resizeMethodImage resize mode. Accepted values: contain or crop. Default: contain.

Preview and Input Options

OptionDescription
filesizeBaseBase used to format displayed file sizes. Default: 1000.
addRemoveLinksAdds remove or cancel links to file previews. Default: false.
previewsContainerElement or selector used to contain previews. Default: null, which uses the Dropzone element.
disablePreviewsDisables preview rendering. Default: false.
hiddenInputContainerContainer for the hidden file input. Accepts a selector or element. Default: body.
previewTemplateHTML string used to create each file preview. Default: Dropzone’s built-in preview template.
forceFallbackForces the fallback file input workflow. Default: false.

File Naming Options

OptionDescription
renameFileFunction that returns the upload filename for a file. Default: null.
renameFilenameDeprecated filename callback retained for backwards compatibility. Default: null. Use renameFile.

Message and Localization Options

OptionDescription
dictDefaultMessageInitial drop-area message. Default: Drop files here to upload.
dictFallbackMessageMessage shown when the browser cannot use the Dropzone workflow.
dictFallbackTextText inserted before the fallback form.
dictFileTooBigMessage for a file above maxFilesize. Supports {{filesize}} and {{maxFilesize}}.
dictInvalidFileTypeMessage for a file rejected by the built-in file type check.
dictThumbnailErrorMessage for an image that cannot be decoded for thumbnail generation.
dictResponseErrorMessage for an invalid server response. Supports {{statusCode}}.
dictCancelUploadText for the cancel-upload link.
dictUploadCanceledMessage emitted after a manual upload cancellation.
dictCancelUploadConfirmationConfirmation text shown before canceling an upload.
dictRemoveFileText for the remove-file link.
dictRemoveFileConfirmationOptional confirmation text shown before removing a file. Default: null.
dictMaxFilesExceededMessage used after the maximum file count is exceeded. Supports {{maxFiles}}.
dictFileSizeUnitsLabels used by filesize() for TB, GB, MB, KB, and bytes.

Configuration Callbacks

OptionDescription
initRuns after the Dropzone instance initializes. Default: empty function.
paramsObject or function for extra request parameters. The default function returns Dropzone chunk metadata for chunked uploads.
acceptCustom acceptance callback. Receives file and done. The default calls done().
chunksUploadedRuns after every chunk for one file has uploaded. Receives file and done.
fallbackRuns when fallback mode is required. The default renders Dropzone’s fallback form.
resizeCalculates source and destination dimensions for thumbnail rendering.
transformFileTransforms a file before upload. The default uses the image resize settings when applicable.

Event Handler Options

Every event listed in the Dropzone Events section can also be assigned as a configuration option. Assigning an event handler in the configuration object replaces Dropzone’s default handler for that event. Use .on() when you only need an additional listener.

OptionDescription
dropDefault UI handler for a file drop.
dragstartDefault handler for drag start.
dragendDefault UI handler for drag end.
dragenterDefault UI handler for drag entry.
dragoverDefault UI handler while files remain over the Dropzone.
dragleaveDefault UI handler when dragged files leave the Dropzone.
resetRestores the Dropzone element to its initial state.
addedfileCreates the default preview UI for one file.
addedfilesDefault handler for a batch of newly added files.
removedfileRemoves the file preview from the DOM.
thumbnailUpdates preview thumbnail markup after thumbnail generation.
errorApplies the default error state and error message.
errormultipleDefault handler for a multiple-file request error.
processingApplies the default processing state to one file.
processingmultipleDefault handler when a multiple-file request starts processing.
uploadprogressUpdates the default per-file progress UI.
totaluploadprogressDefault handler for aggregate upload progress.
sendingDefault handler just before one file request is sent.
sendingmultipleDefault handler just before a multiple-file request is sent.
successApplies the default success state.
successmultipleDefault handler for a successful multiple-file request.
canceledConverts a canceled upload into Dropzone’s default error state.
canceledmultipleDefault handler for cancellation of a multiple-file request.
completeApplies the default completed state.
completemultipleDefault handler after a multiple-file request completes.
maxfilesexceededDefault handler when another file exceeds maxFiles.
maxfilesreachedDefault handler when the accepted file count reaches maxFiles.
queuecompleteDefault handler after the upload queue has finished.
pasteHandler option present in defaultOptions. The built-in paste DOM listener is disabled in the v6.1.0 source.

Dropzone Methods

Event Emitter Methods

MethodDescription
on(event, fn)Registers a listener for a Dropzone event and returns the instance.
off(event, fn)Removes one listener, all listeners for an event, or every listener when called with no arguments.
emit(event, ...args)Emits a Dropzone event and dispatches the corresponding dropzone:event DOM CustomEvent.
makeEvent(eventName, detail)Creates the DOM CustomEvent used by emit().

File State and Queue Methods

MethodDescription
getAcceptedFiles()Returns all accepted files.
getRejectedFiles()Returns all rejected files.
getFilesWithStatus(status)Returns files that match one Dropzone status value.
getQueuedFiles()Returns files with Dropzone.QUEUED status.
getUploadingFiles()Returns files with Dropzone.UPLOADING status.
getAddedFiles()Returns files with Dropzone.ADDED status.
getActiveFiles()Returns queued and uploading files.
addFile(file)Adds one file, runs acceptance checks, generates a thumbnail when applicable, and queues it according to the current options.
enqueueFile(file)Moves an accepted added file into the queue.
enqueueFiles(files)Queues multiple files.
processQueue()Processes queued files while respecting parallelUploads.
processFile(file)Processes one file.
processFiles(files)Processes a group of files and begins the upload workflow.
cancelUpload(file)Cancels an active or queued upload and updates its status.
removeFile(file)Removes one file and emits removedfile.
removeAllFiles(cancelIfNecessary)Removes all non-uploading files. Pass true to cancel active uploads too.
uploadFile(file)Passes one file directly to uploadFiles().
uploadFiles(files)Runs file transformation and upload request logic for one or more files.

Preview and Image Methods

MethodDescription
filesize(size)Formats a byte count using filesizeBase and dictFileSizeUnits.
resizeImage(file, width, height, resizeMethod, callback)Resizes an image before upload and passes the resized Blob to the callback.
createThumbnail(file, width, height, resizeMethod, fixOrientation, callback)Reads a File and generates thumbnail data.
createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin)Generates a thumbnail from an image URL.
displayExistingFile(mockFile, imageUrl, callback, crossOrigin, resizeThumbnail)Adds an existing server file to the Dropzone preview UI.

Lifecycle and Low-level Instance Methods

These methods are exposed on the v6.1.0 class. Several are used by Dropzone’s own workflow and are less stable integration points than the queue, file, and event methods above.

MethodDescription
init()Builds the hidden input, default message, listeners, and initial instance state.
destroy()Disables the instance, removes files and its hidden input, and detaches the instance from the element.
updateTotalUploadProgress()Recalculates aggregate progress and emits totaluploadprogress.
getFallbackForm()Returns the fallback upload fields or form.
getExistingFallback()Finds an existing fallback element inside the Dropzone.
setupEventListeners()Attaches the stored DOM event listeners.
removeEventListeners()Detaches the stored DOM event listeners.
disable()Disables interaction, removes DOM listeners, and cancels files.
enable()Re-enables interaction and DOM listeners.
drop(event)Handles a file drop and passes dropped files into Dropzone.
paste(event)Processes clipboard file items when invoked. The built-in paste DOM listener is disabled in v6.1.0.
handleFiles(files)Passes a list of files to addFile().
accept(file, done)Runs built-in size, type, and file-count checks before calling the configured accept callback.
resolveOption(option, ...args)Returns a plain option value or calls a function-valued option with the supplied arguments.
submitRequest(xhr, formData, files)Sends the prepared XHR with either FormData or a raw binary body.

Static Methods and Helpers

MethodDescription
Dropzone.optionsForElement(element)Returns the declarative configuration stored for an element ID.
Dropzone.forElement(element)Returns the Dropzone instance attached to an element or selector.
Dropzone.discover()Finds .dropzone elements and instantiates those not disabled through Dropzone.options.
Dropzone.isBrowserSupported()Checks the browser APIs and Dropzone’s blocked-browser rules.
Dropzone.dataURItoBlob(dataURI)Converts a base64 data URI to a Blob.
Dropzone.createElement(string)Creates one DOM node from an HTML string.
Dropzone.elementInside(element, container)Checks whether an element is the container or one of its descendants.
Dropzone.getElement(el, name)Resolves a selector or DOM element and throws for an invalid value.
Dropzone.getElements(els, name)Resolves selectors, DOM elements, or element arrays into an element list.
Dropzone.confirm(question, accepted, rejected)Runs the confirmation callback flow. The default implementation uses window.confirm().
Dropzone.isValidFile(file, acceptedFiles)Checks a file against the acceptedFiles MIME type and extension syntax.
Dropzone.uuidv4()Generates the UUID used for upload metadata.

Static Properties and File Status Constants

PropertyDescription
Dropzone.optionsObject used for per-element declarative configurations.
Dropzone.instancesArray containing active Dropzone instances.
Dropzone.blockedBrowsersRegular expressions for browsers that expose required APIs but have known incompatible behavior.
Dropzone.ADDEDStatus string added.
Dropzone.QUEUEDStatus string queued.
Dropzone.ACCEPTEDBackwards-compatible alias of Dropzone.QUEUED.
Dropzone.UPLOADINGStatus string uploading.
Dropzone.PROCESSINGAlias of Dropzone.UPLOADING.
Dropzone.CANCELEDStatus string canceled.
Dropzone.ERRORStatus string error.
Dropzone.SUCCESSStatus string success.

Dropzone Events

Register event listeners with uploader.on(eventName, callback). Dropzone v6.1.0 exposes the following events in its instance event list.

EventFires When
dropFiles are dropped onto the Dropzone element.
dragstartA drag operation starts over the Dropzone.
dragendA drag operation ends.
dragenterDragged files enter the Dropzone.
dragoverDragged files move over the Dropzone.
dragleaveDragged files leave the Dropzone.
addedfileOne file is added.
addedfilesA group of files is added through a file selection or drop.
removedfileA file is removed.
thumbnailA thumbnail is ready for an image file.
errorOne file encounters validation or upload failure.
errormultipleA request containing multiple files fails.
processingOne file enters the upload-processing state.
processingmultipleA multiple-file request enters the processing state.
uploadprogressProgress changes for one file. The callback receives the file, percentage, and bytes sent.
totaluploadprogressAggregate upload progress changes. The callback receives percentage, total bytes, and total bytes sent.
sendingOne file request is about to be sent.
sendingmultipleA multiple-file request is about to be sent.
successOne file finishes successfully.
successmultipleA multiple-file request finishes successfully.
canceledOne upload is canceled.
canceledmultipleA multiple-file request is canceled.
completeOne file finishes with either success or error.
completemultipleA multiple-file request finishes.
resetThe file list becomes empty and the Dropzone returns to its initial state.
maxfilesexceededA newly added file exceeds maxFiles.
maxfilesreachedThe accepted file count reaches maxFiles.
queuecompleteNo added, queued, or uploading files remain after completion.
uploader.on("sending", function (file, xhr, formData) {
  formData.append("documentId", "invoice-482");
});
uploader.on("uploadprogress", function (file, progress, bytesSent) {
  console.log(file.name, progress, bytesSent);
});
uploader.on("success", function (file, response) {
  console.log("Uploaded:", file.name, response);
});
uploader.on("error", function (file, message) {
  console.error("Upload failed:", file.name, message);
});
uploader.on("queuecomplete", function () {
  console.log("All queued uploads finished");
});

Server-side Upload Requirements

Dropzone handles the browser side of the upload. Your server endpoint receives and stores the files. Normal uploads use multipart form data and the default field name is file.

Client-side limits such as acceptedFiles and maxFilesize improve form feedback. The server must validate file type, size, permissions, and storage rules before accepting uploaded data.

Chunked uploads send chunk metadata through params. The backend must save and assemble the parts. The chunksUploaded callback can run finalization logic after every chunk for a file has finished.

Alternatives and Related Resources

FAQs

Q: Does Dropzone.js upload and store files on the server?
A: Dropzone sends files from the browser to the configured URL. Your backend must receive, validate, and store each upload.

Q: Why does a class="dropzone" form not initialize automatically in Dropzone 6?
A: Dropzone 6 removed automatic discovery. Call Dropzone.discover() after the form exists, or create the Dropzone instance directly with new Dropzone(...).

Q: How do I restrict file types and file sizes?
A: Set acceptedFiles, maxFilesize, and maxFiles in the configuration object. Apply equivalent validation on the server.

Q: How do I wait for a button click before uploading?
A: Set autoProcessQueue to false. Call processQueue() from the button handler when the files are ready for transfer.

Changelog

v6.2.1 (09/12/2026)

  • Update

v6.2.0 (09/07/2026)

  • addedfiles now reports the files found inside a dropped folder.
  • parallelChunkUploads: true now starts at most parallelUploads chunks at a time rather than every chunk of the file at once.
  • Add resizeTransparencyFill, the color shown through transparent parts of a resized image.

v6.1.0 (09/05/2026)

  • Introduced dictThumbnailError for image files that cannot be decoded.
  • Corrected chunk offsets when chunkSize arrives as a string.
  • Prevented preview thumbnails from being dragged back into the upload area as duplicate files.
  • Corrected zero-byte uploads when forced chunking is active.

v6.0.0 (09/05/2026)

  • Promoted the 6.0 line to stable.
  • Removed Internet Explorer compatibility and several legacy APIs and distribution files.
  • Reduced bundle size for the current browser baseline.
  • Kept the API unchanged from 6.0.0-beta.2.

You Might Be Interested In:


Leave a Reply