Created
May 26, 2019 15:57
-
-
Save artlili/2bc158b8cdc97c8206e52e2374283f2d to your computer and use it in GitHub Desktop.
Axios upload multiple files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" ref="file" multiple="multiple"> | |
submitFiles() { | |
let formData = new FormData(); | |
for( var i = 0; i < this.$refs.file.files.length; i++ ){ | |
let file = this.$refs.file.files[i]; | |
console.log(file); | |
formData.append('files[' + i + ']', file); | |
} | |
axios.post( '/fileupload', formData, { | |
headers: { | |
'Content-Type': 'multipart/form-data' | |
}, | |
} | |
).then(function(){ | |
}) | |
.catch(function(){ | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment