Dropzone is a wrapper around Dropzone.js that provides a drag-and-drop file upload area
with Metronic styling. Uploaded file content is stored as a Data URL (for media) or text (for CSV, etc.) in a hidden input element.
Import
import {components} from 'metronic-extension';
const {Dropzone} = components;
Constructor
new Dropzone(element, options)
Parameter
Type
Description
element
string | HTMLElement
CSS selector string or HTMLElement.
options
DropzoneOptions
Configuration options for the dropzone.
DropzoneOptions
Property
Type
Default
Description
hiddenInputContent
HTMLInputElement
-
Hidden input to store uploaded content (Data URL or text).
acceptedFiles
string
-
Comma-separated MIME types or extensions. e.g. "image/*,application/pdf,.psd"
maxFilesize
number
-
Maximum file size in bytes.
dictDefaultMessage
string
"Drop files here to upload"
Drop zone title text.
dictDescriptionMessage
string
-
Drop zone description text.
dictFileTooBig
string
-
Error message when file exceeds max size.
Methods
Method
Return
Description
onAddFile(handler)
Dropzone
Callback when a file is added. Receives the DropzoneFile object.
onCancelFile(handler)
Dropzone
Callback when file upload is cancelled.
Basic Example
A simple drag-and-drop file upload area. Drop or click to select a file.