[Vuejs]-Vue.Js Not Sending Files To Backend

1👍

Try

let length = event.target.files.length

instead of…

let length = event.target.files.count

1👍

I think there are a couple issues.

let formData = new FormData;

should be

let formData = new FormData();

and you need to specify headers

axios.post('/upload/files', formData, {
    headers: {
        'content-type': 'multipart/form-data'
    }
}).then(x => {
    console.log(x);
});

1👍

You should try this

let formData = new FormData(event.target);

In function as:

uploadFile(event){
   let formData = new FormData(event.target);
    console.log(formData);

  axios.post('/upload/files', formData).then(x => {
     console.log(x);
 });
}

Leave a comment