How to upload multiple files with additional field react.js flask
Try this. Notice the 'files'
key while appending form data. Let me know if it works
UPDATED ANS
let formData = this.state; const fd = new FormData(); for(const k of formData){ fd.append('files',k.file, k.name); };
you are not sending a file value, so requests.files['files']
will be empty.
fd.append("file", files[0]); // replace files[0] with your filefd.append("name", "tmp");
now you'll see that requests.files['file']
is filled with your file,and request.form
is filled with 'name' key and its value.
note that it's not the key name that fills requests.files
, it is filled based on it's value (it should be file object)
you can create a structure like name1
for file1
metadata and name2
for file2
metadata.