使用axios怎么往后端传输MultipartFile文件?
来源:1-3 初学编写 HelloWorld 和 Counter

warren_au
2022-10-07
我自己联系的案例中使用axios往后端上传图片,后端是springboot
使用postman测试过上传MultipartFile没问题
后端接收文件
@RequestParam(value = “files”)MultipartFile[] multipartFiles
可是当我在前端使用axios上传antdesign组件中的文件时。后端就会报错误
Current request is not a multipart request
或
the request was rejected because no multipart boundary was found
前端axios
let responseUpload = await axios.post(port + “property/uploadPropertyPhoto?propertyId=” + response.data.data.id,
{
files:values.fileList.fileList
},{
headers:{
‘Content-Type’: ‘multipart/form-data’
},
}
);
request payload可以看出文件已经携带在request里了
请问这个问题该怎么解决,很急试了很多次都不行
写回答
1回答
-
Dell
2022-10-16
把请求的 header 体里的内容在控制台里打印一下,发一下
00
相似问题
引入外部文件的问题
回答 2
请问怎么才能去掉链接里面的# ?
回答 1