Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dropzone

dropzone2.1mMIT6.0.0-beta.2TypeScript support: definitely-typed

Handles drag and drop of files for you.

dragndrop, drag and drop, file upload, upload

readme

Dropzone.js

Test and Release

Dropzone is a JavaScript library that turns any HTML element into a dropzone. This means that a user can drag and drop a file onto it, and Dropzone will display file previews and upload progress, and handle the upload for you via XHR.

It's fully configurable, can be styled according to your needs and is trusted by thousands.

Dropzone Screenshot

Quickstart

Install:

$ npm install --save dropzone
# or with yarn:
$ yarn add dropzone

Use as ES6 module (recommended):

import { Dropzone } from "dropzone";
const dropzone = new Dropzone("div#myId", { url: "/file/post" });

or use as CommonJS module:

const { Dropzone } = require("dropzone");
const dropzone = new Dropzone("div#myId", { url: "/file/post" });

👉 Checkout our example implementations for different bundlers

Not using a package manager or bundler?

Use the standalone files like this:

<script src="https://unpkg.com/dropzone@5/dist/min/dropzone.min.js"></script>
<link
  rel="stylesheet"
  href="https://unpkg.com/dropzone@5/dist/min/dropzone.min.css"
  type="text/css"
/>

<div class="my-dropzone"></div>

<script>
  // Dropzone has been added as a global variable.
  const dropzone = new Dropzone("div.my-dropzone", { url: "/file/post" });
</script>


⚠️ NOTE: We are currently moving away from IE support to make the library more lightweight. If you don't care about IE but about size, you can already opt into 6.0.0-beta.1. Please make sure to pin the specific version since parts of the API might change slightly. You can always read about the changes in the CHANGELOG file.

Community

If you need support please use the discussions section or stackoverflow with the dropzone.js tag and not the GitHub issues tracker. Only post an issue here if you think you discovered a bug.

If you have a feature request or want to discuss something, please use the discussions as well.

⚠️ Please read the contributing guidelines before you start working on Dropzone!

Main features ✅

  • Beautiful by default
  • Image thumbnail previews. Simply register the callback thumbnail(file, data) and display the image wherever you like
  • High-DPI screen support
  • Multiple files and synchronous uploads
  • Progress updates
  • Support for large files
    • Chunked uploads (upload large files in smaller chunks)
  • Support for Amazon S3 Multipart upload
  • Complete theming. The look and feel of Dropzone is just the default theme. You can define everything yourself by overwriting the default event listeners.
  • Browser image resizing (resize the images before you upload them to your server)
  • Well tested

MIT License

See LICENSE file

changelog

6.0.0-beta.2

  • Add binaryBody support (thanks to @patrickbussmann and @meg1502).
    • This adds full support for AWS S3 Multipart Upload.
    • There is an example setup for this now in test/test-sites/2-integrations.

6.0.0-beta.1

Breaking

  • Dropzone is dropping IE support! If you still need to support IE, please use 5.9.3. You can download it here: https://github.com/dropzone/dropzone/releases/download/v5.9.3/dist.zip
  • Dropzone.autoDiscover has been removed! If you want to auto discover your elements, invoke Dropzone.discover() after your HTML has loaded and it will do the same.
  • The dropzone-amd-module files have been removed. There is now a dropzone.js and a dropzone.mjs in the dist folder.
  • The min/ folder has been removed. dropzone.min.js is now the only file that is minimized.
  • Remove Dropzone.extend and replace by the just-extend package.
  • There is no more Dropzone.version.

5.9.3

  • Fix incorrect resize method used for creating thumbnails of existing files (thanks to @gplwhite)

5.9.2

  • Handle xhr.readyState in the submitRequest function and don't attempt to send if it's not 1 (OPENED). (thanks to @bobbysmith007)

5.9.1

  • Fix the way upload progress is calculated when using chunked uploads. (thanks to @ckovey)

5.9.0

  • Properly handle when timeout is null or 0
  • Make the default of timeout null

5.8.1

  • Fix custom event polyfill for IE11
  • Fix build to use ES5 instead of ES6, which was broken due to webpack upgrade. (thanks to @fukayatsu)

5.8.0

  • Dropzone now also triggers custom events on the DOM element. The custom events are the same as the events you can listen on with Dropzone but start with dropzone:. (thanks to @1cg)
  • Moved the ./src/options.js previewTemplate in its own preview-template.html file.
  • Switched to yarn as the primary package manager (shouldn't affect anybody that is not working Dropzone itself).

5.7.6

  • Revert dist/min/*.css files to be named dist/min/*.min.css.
  • Setup bower releases.

5.7.5

  • Rename blacklistedBrowsers to blockedBrowsers (but still accept blacklistedBrowsers for legacy).
  • Add automatic trigger for packagist deployment.
  • Fix links in package.json.

5.7.4

  • Prevent hidden input field from getting focus (thanks to @sinedied)
  • Fix documentation of maxFilesize (thanks to @alxndr-w)
  • Fix build issues so the UMD module can be imported properly

5.7.3 (retracted)

  • Add disablePreviews option.
  • Fix IE problems with Symbols.
  • WARNING: This release had issues because the .js files couldn't be imported as AMD/CommonJS packages properly. The standalone version worked fine though. I have retracted this version from npm but have left the release on GitHub.

5.7.2

  • Base the calculation of the chunks to send on the transformed files
  • Properly display seconds (instead of ms) in error message when timeout is reached
  • Properly handle it when options.method is a function (there was a bug, which always assumed that it was a String) (thanks to @almdac)
  • Fix orientation on devices that already handle it properly (thanks to @nosegrind)
  • Handle additionalParams when they are an Array the way it's expected (thanks to @wiz78)
  • Check for string in error message type instead of String (thanks to @RuQuentin)

5.7.1

  • Fix issue with IE (thanks to @Bjego)

5.7.0

  • Cleanup the SVGs used to remove IDs and sketch attributes Since SVGs are duplicated this resulted in duplicate IDs being used.
  • Add a dedicated displayExistingFile method to make it easier to display server files.
  • Fix an error where chunked uploads don't work as expected when transforming files before uploading.
  • Make the default text a button so it's discoverable by keyboard.

5.6.1

  • Re-released due to missing javascript files
  • Removes npm dependency that got added by mistake

5.6.0

  • Timeout now generates an error (thanks to @mmollick)
  • Fix duplicate iteration of error processing (#159 thanks @darkland)
  • Fixed bootstrap example (@thanks to @polosatus)
  • The addedfiles event now triggers after each individual addedfile event when dragging files into the dropzone, which is the same behavior as when clicking it.

5.5.0

  • Correct photo orientation before uploading (if enabled) (thanks to @nosegrind)
  • Remove a potential memory leak in some browsers by keeping a reference to xhr inside the individual chunk objects (thanks to @clayton2)
  • Allow HTML in the remove links (thanks to @christianklemp)
  • hiddenInputContainer can now be an HtmlElement in addition to a selector String (thanks to @WAmeling)
  • Fix default values on website (since the last deployment, the default values all stated null)

5.4.0

  • Fix IE11 issue when dropping files

5.3.1

  • Fix broken npm release of 5.3.0

5.3.0

  • Add dictUploadCanceled option (thanks to @Fohlen)
  • Fix issue with drag'n'drop on Safari and IE10 (thanks to @taylorryan)
  • Fix issues with resizing if SVG files are dropped (thanks to @saschagros)

5.2.0

  • Migrated from coffeescript to ES6!
  • Added chunked file uploading! The highly requested chunked uploads are now available. Checkout the chunking option documentation for more information.
  • Fixed a faulty console.warning (should be console.warn)
  • If an input field doesn't have a name, don't include it when sending the form (thanks to @remyj38)
  • Opera on Windows Phone is now also blacklisted (thanks to @dracos1)
  • If a custom preview element is used, it is now properly handled when it doesn't have a parent (thanks to @uNmAnNeR)

5.1.1

  • Fix issue where showing files already on the server fails, due to the missing file.upload.filename
  • Fix issue where file.upload.filename gets removed after the file uploaded completed
  • Properly handle arraybuffer and blob responses

5.1.0

  • Add possibility to translate file sizes. (#16 thanks to @lerarybak for that)
  • Fix duplicate filenames in multiple file uploads (#15)
  • The renameFilename option has been deprecated. Use renameFile instead (which also has a slightly different function signature)
  • The renameFile option now stores the new name in file.upload.filename (#1)

5.0.1

  • Add missing dist/ folder to npm.

5.0.0

  • Add support for browser image resizing! Yes, really. The new options are: resizeWidth, resizeHeight, resizeMimeType and resizeQuality. Thanks a lot to MD Systems for donating the money to make this a reality.
  • Fix IE11 issue with options.timeout
  • Resolve an issue that occurs in the iOS squashed image fix, where some transparent PNGs are stretched inaccurately

4.4.0

  • Add options.timeout

4.3.0

Added Changelog. Sorry that this didn't happen sooner.