I am using axios to upload multiple files and some other stuff. Among this other stuff are arrays of integers (from checkboxes) and some boolean values.
At first I tried this:
axios.post(this.route, {
name: this.name,
...
photos: this.photos
})
And everything was perfect except that the backend received the photos as empty objects. So I tried the following
let formData = new FormData()
formData.append('name', this.name)
...
for(let i = 0; i < this.photos.length; i++) {
let photo = this.photos[i]
formData.append('photos['+i+']', photo)
}
axios.post(this.route, formData)
And the photos worked just fine, but other data like arrays and boolean values from radios started coming wrong. FormData transforms them into strin, and before the backend was receiving them like arrays and booleans directly, I want that. I am using Laravel as backend and the validations do not pass that way.