P.Macs
P.Macs

Reputation: 77

How to get all the names in dropzone in reactjs

I'm having difficulty on getting all the file name I dropped; I only get the first dropped item name but I needed all the names so i can upload it all. Here is the sample of my dropzone:

onDrop(acceptedFiles) {
    debugger
    console.log('Received files: ', acceptedFiles);
    this.setState({files: acceptedFiles});
    let {form} = this.props.timeline;       

        acceptedFiles.map(file =>  { 
            form.Name=file.name
        });

}

and here is what happens in the dropzone debugged enter image description here

Upvotes: 0

Views: 114

Answers (1)

hequ
hequ

Reputation: 771

Your acceptedFiles already contains all the filenames but the filename is encapsulated inside the object which also seems to contain the TimelineKeyas well.

If you only want the filenames then you need to modify your code a bit:

const filenames = acceptedFiles.map(file => (file.name))

Then you have the collection of filenames and you can do what ever you want with it.

Upvotes: 1

Related Questions