<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5HGSQD2L" height="0" width="0" style="display:none;visibility:hidden" title="GTM"></iframe>

File Dropzone (draft)

Select and upload or drag and drop a file/s from the users local file system.

Inside of a Form

The FileDropzone component is intended to be a wrapper around a FileInput component to extend functionality to include drag and drop.

The preview has been updated.

Single File Upload

When multiple file upload is not enabled (on FileInput), add the FileTile as a child of the FileDropzone 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 FileInput. An example of some common file validation has been provided below, feel free to copy/paste and update as necessary.

FileInput accept prop

Per the validation code snippet below, we have provided an example of sharing the same values in the FileInput 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.

Share

Full Implementation

This is an example of how you might implement the FileDropzone with FileTiles and file validation. Feel free to take this and tweak as necessary for your use case.

The preview has been updated.

Forms

When using FileDropzone in a form, ensure it is wrapped in it's own FormField and FormInputGroup. You can then utilise form component such as FormHelper to provide helper text. When FileTiles are rendered within the same FormField, the component will automatically pickup any errors passed through to FileTile to link them with the FileDropzone. Please see the Full Implementation example in the Usage tab.