我有一个具有文件和提交按钮的表单,一旦提交表单,我必须将图像文件发布到服务器。提交表单后,我收到错误请求错误,这是我的代码也是我共享的错误
uploadCategoryImages = () => {
const formData = new FormData();
console.log(categoryImageArray)
formData.append('images', categoryImageArray)
api.post('/api/v1/addimage/category/2', formData)
.then((res) => {
console.log("Successs", res)
})
.catch((error) => {
console.log("Error :", error);
})
}
categoryImageArray是具有base64映像的数组
["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD…
ed+q879V536rzv1XnfqvO/Ved+q879UKjBxwvXGsf+cf/2Q=="]
我得到的错误是
Error : Error: Request failed with status code 400
at createError (createError.js:16)
at settle (settle.js:18)
at XMLHttpRequest.handleLoad (xhr.js:77)