I am trying to upload an image, but the form data simply doesn't append the file data to my request.
Front end:
const form = new FormData()
form.append('files[]', file)
form.append("woor","w")
console.log(file)
const header = {
headers: { 'Content-Type': 'multipart/form-data'}
}
axios.post(
action,
form,
header
).then(({ data: response }) => {})
Flask backend:
def upload():
print(request.form)
print(request.json)
return {"body":[{"value":"fdd", "label":"fdaad"}]}
The backend prints out ImmutableMultiDict([('woor', 'w')])
but not the file, console.log
does show the file data
I have also tried {"file":file}
and {"file[]":file}
EDIT:
file
is not an array. It looks like a dict
to me from console.log()
question from:
https://stackoverflow.com/questions/65896539/react-formdata-not-sending-image-data-to-flask-backend 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…