[Vuejs]-Send form with file VueJS

3đź‘Ť

âś…

had this issue a few months ago. the problem was that the file wasn’t attached to the javascript formData object and you need to do so manually before you submit formDate to the backend with whatever http-client you’re using

try to create a new data property called file and then in your file input tag write
v-model=”file” so it has that file

then before the post request try to attach that file property to the formData object maybe with something like that

let formData = new FormData();
formData.append('file', this.file);

It worked for me when I was trying to solve that issue and it should work with you too. if it doesn’t, just let me know

👤Omar Abdo

Leave a comment