Use File Dropzone...
- For uploading one or more files.
- For uploading files by dragging and dropping.
Don't use File Dropzone...
- To show the progress of uploading. Use File Tile instead.
- When space on a page is limited. Use File Input instead.
Default
The File Dropzone component extends the functionality of File Input to include drag and drop functionality.
The preview has been updated.
Inside of a Form
Since it is a form element, File Dropzone can be used inside a Standard Form along with a separate, external label and/or helper text. Helper text should display upload criteria such as accepted file formats and maximum file size.
The preview has been updated.
Single File Upload
When multiple file upload is not enabled (on File Input), add the File Tile as a child of the File Dropzone which applies specific styling for single file upload. When multiple files are dropped on the dropzone and it's not enabled, then the dropzone will show an error on drag and only pass the first file to the input's onChange
event.
The preview has been updated.
Disabled
To disable the FileDropzone
, add the disabled
prop on the FileInput
.
The preview has been updated.
Validation
You may want to validate files when the user adds files to the dropzone such as accepted file types, max file size and total number of files. We recommend that you do this during the onChange
event of the File Input. An example of some common file validation has been provided below, feel free to copy/paste and update as necessary.
File Input accept prop
Per the validation code snippet below, we have provided an example of sharing the same values in the File Input accept
prop for the accepted file validation. Note that this method is recommended but you must only use individual mime types unless you update the validation function to handle wildcards. See a full implementation in the next section.
Full Implementation
This is an example of how you might implement the File Dropzone with File Tiles and file validation. Feel free to take this and tweak as necessary for your use case.
The preview has been updated.