react-dropzone-component is one of the most popular drag and drop JavaScript libraries. It is free, fully open source, and makes it easy for you to handle dropped files on your website.
import React, { useState } from 'react';
import { DropzoneComponent } from 'react-dropzone-component';
import "dropzone/dist/dropzone.css";
const DropzoneBasicExample = () => {
//DropZone Config
var djsConfig = {
addRemoveLinks: true,
acceptedFiles: "image/jpeg,image/png,image/gif",
autoProcessQueue: false,
uploadprogress: 100
};
var componentConfig = {
iconFiletypes: [".jpg", ".jpeg", ".png", ".gif"],
showFiletypeIcon: true,
postUrl: "no-url"
};
const handleFileAdded = (file) => {
console.log(file);
}
return (
<>
<DropzoneComponent
config={componentConfig}
djsConfig={djsConfig}
eventHandlers={handleFileAdded}
/>
</>
);
}
export default DropzoneBasicExample;