I have a form using Vuetify which takes in text and a couple of images. The form works if I don't include the images, but with them, I get the error GET http://danza.test/thumbnails[object%20File] 404 (Not Found)
.
How do I pass images across in a form along side text?
Part of form handling input:
<v-row>
<v-col cols="12" sm="6" md="6">
<v-file-input v-model="editedItem.image" label="Picture"></v-file-input>
</v-col>
<v-col cols="12" sm="6" md="6">
<v-file-input v-model="editedItem.thumbnail" label="Thumbnail"></v-file-input>
</v-col>
</v-row>
item object
editedItem: {
name: '',
image: null,
thumbnail: null,
species: '',
tag: '',
patreon: '',
action: '',
},
defaultItem: {
name: '',
image: null,
thumbnail: null,
species: '',
tag: '',
patreon: '',
action: '',
},
upload function
saveToServer () {
if (this.editedIndex > -1) {
// Edit item
Object.assign(this.images[this.editedIndex], this.editedItem);
axios.put('/api/gallery/' + this.images[this.editedIndex].id, this.editedItem).then((response) => {
})
.catch(function (error) {
console.log(error);
})
} else {
//New item
let $updatedGallery = this;
let $index = this.images.push(this.editedItem)-1;
axios.post('/api/gallery', this.editedItem, {headers: {'Content-Type': 'multipart/form-data'}})
.then((response) => {
$updatedGallery.editedItem.id = response.data.id;
Object.assign($updatedGallery.images[$index], $updatedGallery.editedItem);
})
.catch(function (error) {
console.log(error);
});
}