I have some problems with uploading multiple files in Vue with Axios. The problem is that the FileList always returns a length of 0, even if I select multiple files.
I have a button which opens a File Upload:
<v-icon @click="attachFile(user)">fas fa-paperclip</v-icon>
The function it calls:
attachFile(user) {
document.getElementById(user.id).click();
},
The form input it refers to:
<input
:id="item.id"
name="files[]"
type="file"
multiple
hidden
ref="files"
@change="handleUpload()"
/>
And then in the handleUpload() I want to make an axios call to upload the files.
handleUpload() {
this.files = this.$refs.files.files;
console.log(this.files);
},
But this.files always returns a FileList with the length of 0. I already set the file data in the function:
data: () => ({
files: "",
})