Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a material ui dropzone area not allow duplicates?

I'm using https://yuvaleros.github.io/material-ui-dropzone/ and I'm trying to make it so that it doesn't allow uploading duplicates of previously uploaded files.

I've tried on onchange function that removes the file from the <input type="file"> if there's already a file with that name that is embedded into <DropzoneArea> but I don't know how to remove this graphic:

I've also looked at the documentation of the Material UI Dropzone, without any luck

like image 354
Sheshank S. Avatar asked Jul 31 '20 20:07

Sheshank S.


1 Answers

You can use DropzoneAreaBase which allows you to fine tune the component. You can control the files list via passing the files in the fileObjects array and updating in the onAdd/onDelete using your logic.

Edit immutable-architecture-vq8hb

Note, you can play around with the snackbar to not show anything when an existing file was added, I'll leave this up to you.

like image 161
Mordechai Avatar answered Sep 18 '22 12:09

Mordechai