我的django rest框架在与ReactJs一起发送文件时返回了400错误的请求,而邮递员成功地上传了具有相同参数的相同文件。当我进一步调查时,我发现从API返回的错误是“未提交文件”。
提交处理程序
.
状态:
submitHandler(event){
event.preventDefault()
const data = new FormData()
data.append('file', this.state.selectedFile)
axios
.post('http://localhost:8000/files/', data, {})
.then(res => {
console.debug(res.statusText)
})
.catch(err => {
console.debug(err)
})
}