📅  最后修改于: 2023-12-03 15:14:48.056000             🧑  作者: Mango
Dropzone.js is an open source library that provides drag-and-drop file uploads with image previews. It is a lightweight, easy-to-use library that can be integrated seamlessly into any web project.
To get started with Dropzone.js, simply include the following files in your HTML document:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.css" integrity="sha512-PxNZtpIe/GzjPpjbFgX987GtGeHThdOIsLyBy40bBj+oBvBLfOik/AJsOZjKwkTfq9Q+Nbinr3qyF+ApVcA4MQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.2/dropzone.min.js" integrity="sha512-Bz+X9CsJ75cdWmckaMsyF0VmJ7klMQQS4wq4OPRBuZQTPrL6l0vRkgWzV8J73DCyNYH+7x224TiEwn5ar27zeg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Then, create a div with the class "dropzone" in your HTML document:
<div class="dropzone"></div>
Finally, initialize Dropzone.js in your JavaScript file:
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(".dropzone", { url: "/file/upload" });
Dropzone.js is a powerful drag-and-drop file upload library that can be easily integrated into any web project. With its many features, including image previews, progress bars, and client-side image resizing, Dropzone.js is an essential tool for any web developer.