0👍
✅
//let formData = new FormData();
for (var i = 0; i < this.photos.length; i++) {
let formData = new FormData();
Fix: Move the formData declaration inside of the for loop. If it’s outside, the final photo gets queued 3 times before being posted. The fix makes sure only the photo in question is queued and sent
0👍
Try this:
submitFiles(axios) {
let formData = new FormData();
for (var i = 0; i < this.photos.length; i++) {
let photo = this.photos[i];
formData.append("photos", photo);
const config = {
headers: {
"content-type": "multipart/form-data; "
}
};
}
this.$axios
.post(`/api/v1/photos/`, formData, config)
.then(response => {
console.log("Successfully Submitted Images");
})
.catch(error => {
console.log(error);
});
},
Source:stackexchange.com