[Vuejs]-How to upload the files using VueJS and Laravel 5.3

0👍

Ok I managed to get this working. Before the file upload I had an array that I was posting via Ajax as you can see below.
I modified it to look like the below in order handle file uploads.

Basically you need to send through a FormData object when uploading files. Uses a FormData object by default when submitting a form – but when only posting a array you need to first append those array values to the FormData object.

You should be able to make sense of the code below…

var formData = new FormData();

                jQuery.each(this.comment.file, function(i, file) {
                    formData.append('file[]', file);
                });
                formData.append('body', this.comment.body);
                formData.append('comments_room_id', this.comment.comments_room_id);
                formData.append('id', this.comment.id);
                formData.append('name', this.comment.name);

                this.$http.post('/api/comment/store', formData).then(function (response) {

Leave a comment