Answer the question
In order to leave comments, you need to log in
How to add a file to a post request in axios?
Vue 2, axios, send form post request:
Object with form:
axios.post( '/addTrack', this.form.data )
form: {
data: {
title : '',
style : '',
authors: [
{
id: '',
rightholder: 1,
percent: ''
}
],
composers: [
{
id: '',
rightholder: 1,
percent: ''
}
],
file: '',
right_area: 1,
},
errors: {
}
}
this.form.data.file = e.target.files[0];
Answer the question
In order to leave comments, you need to log in
The decision was made to do this:
var formData = new FormData( document.getElementById('myForm') );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question