我一直在尝试使用axios上传文件,控制台网络选项卡上的有效负载看起来很棒但是Laravel端的文件似乎是空的。
以下是我从$request->all()
"feedback": {
"description": "there is not a friend",
"displays": [
"Lagos -\r\n Ikoyi"
],
"messages": [
{
"text": "this is an unexpected result",
"startTime": "2018-02-20T11:11:01.404Z",
"endTime": "2018-02-20T11:11:01.411Z",
"image": {},
"video": {}
}
]
}
}
以下是发送方法:
submit() {
const data = new FormData();
data.append('description', this.description);
for (let index in this.boards) {
if (this.boards.hasOwnProperty(index)) {
data.append('displays[' + index + ']', this.boards[index]);
}
}
for (let index in this.messages) {
if (this.messages.hasOwnProperty(index)) {
data.append('messages[' + index + '][text]', this.messages[index].text);
data.append('messages[' + index + '][image]', this.messages[index].imageBlob);
data.append('messages[' + index + '][video]', this.messages[index].videoBlob);
data.append('messages[' + index + '][startTime]', this.messages[index].startTime);
data.append('messages[' + index + '][endTime]', this.messages[index].endTime);
}
}
axios.post('/campaign/', data, {
headers: {
'accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.8',
'Content-Type': `multipart/form-data; boundary=${data._boundary}`,
}
}).then(response => {
this.feedback = response.data;
}).catch(error=>{
this.errors = error
});
}
请问,我该如何解决这个问题?