I'm trying to append uploaded file and a data value to FormData in vue.js. In my controller, only the files request can be assessed.
data() {
return (
file: '',
categ: ''
}
}
And in my method:
var form = new FormData();
var file = this.file;
var cat = this.categ;
form.append('pics', file, cat);
axios.post('/api', form, { headers:
{ 'Content-Type': 'multipart/form-data' }
}).then (res => console.log(res));
What am I doing wrong?
form.append('pics', file, cat);, the third argument,catis the name of the file.