How can we simply upload folder in reactjs?

Nammu picture Nammu · Apr 10, 2019 · Viewed 8.9k times · Source

I am looking here for upload folder in reactjs.I have folder in that doc and docx files are there I just want to upload folder when user click in browse button.where I have to not allowed user for selecting single file. Can someone please give me simple example of folder upload or folder select where user can only select folder not file. Actually I am looking in react-dropzone library but not understanding how can I use this for folder select or upload. If someone can guide me or give me simple example where it showing folder upload example that will be great help.Thanks in Advance.

Answer

Zaif Warm picture Zaif Warm · Apr 10, 2019

You can allow folder upload by adding these attributes empty "webkitdirectory directory" into your react-dropzone input.

like this. <input {...getInputProps()} directory="" webkitdirectory="" type="file" />

by using this user can't select a single file.

its work for me :)