Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we simply upload folder in reactjs?

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.

like image 686
Nammu Avatar asked Apr 10 '19 08:04

Nammu


People also ask

What react component is used to upload files?

The React File Upload is a component for uploading one or multiple files, images, documents, audio, video, and other files to a server.


2 Answers

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 :)

like image 195
Zaif Warm Avatar answered Nov 07 '22 22:11

Zaif Warm


You can allow folder upload by adding theses attributes "webkitdirectory mozdirectory directory" to your input :

 <input type="file" webkitdirectory mozdirectory directory />

but you can't disable the user ability to upload only one file.

like image 24
Nil Avatar answered Nov 07 '22 22:11

Nil