0

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

1
  • The problem with your example is that you map through the acceptedFiles and then you assign the form.name again for each item. This will result that your form.Name will always be the same as the last item's name in the acceptedFiles collection. Commented Jul 4, 2017 at 9:56

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, it will be a collection of names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.