Skip to content
Advertisement

upload multiple files with fetch

I am trying to receive more than one file per time using reactjs and flask api, but I get this error

JavaScript

fontend code using reactjs

JavaScript

backend code using flask

JavaScript

flask receiving the files as [‘[object File],[object File]’] .

I tried to find ways to read an object file but nothing worked can anyone help..

Advertisement

Answer

I don’t use React but for me problem makes

JavaScript

because this.state.file is list with one or many files and it needs for-loop to add every file as separated object in Form

JavaScript

And now it sends all files in request.files instead of one (useless) string '[object File],[object File]' in request.form


Minimal working code

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement