I am trying to receive more than one file per time using reactjs and flask api, but I get this error
data = file.read()
AttributeError: 'str' object has no attribute 'read'
fontend code using reactjs
this.state = {
  file : []
}
fileSelectHandler = (event) => {
  var totalfiles = event.target.files.length;
  for (var index=0; index < totalfiles; index++){
    this.state.file.push(event.target.files[index])
  }
}
    
async onFormSubmit (event) {
   event.preventDefault();
   const formData = new FormData();
   formData.append("file", this.state.file);    
   await fetch(apiUrl+'photo/create' , {
      method: 'POST',
      body: formData
   })
}
backend code using flask
@app.route('/photo/create', methods=['POST'])
def create_photo():
   files = request.form.getlist("file")
   print(files)
   for file in files:
      data = file.read()
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..
 
     
    