Level 4
console.log(file[0]) // gives me the correct File
var formData = new FormData();
formData.append('file',target.file[0]);
Hi,
i am faced with the problem that I cannot send a file to Laravel using axios. I have been trying to find the error for 2 days now...all the solutions I could find at google did not help me. My Response im getting from laravel is always empty. Im just returning the request, so nothing special for now.
Hopefully someone else can give me the right hint: Im Using Laravel 7.6.1 and Vue 3.10.0
onFileInputChange: function (e) {
this.file = e.target.files || e.dataTransfer.files; this.upload(file); }
upload: function (file) {
console.log(file[0]) // gives me the correct File
var formData = new FormData();
formData.append('file', file[0]);
let config = { headers: { 'Content-Type': 'multipart/form-data' } } // tryed with and without this config
axios.post('/api/user/settings', formData, config).then(response => {
console.log(response)
}).catch(err => {
console.log(err.response)
});
}
Thank you kind regards
Please or to participate in this conversation.