element 上傳組件不支持文件夾上傳,。。。使用input的webkitdirectory屬性可上傳文件夾
<input ref="file" class="fileUploaderClass" type='file' name="file" webkitdirectory @change.stop="changesData"/>
changesData () {
console.log(this.$refs.file.files)
this.fileList = this.$refs.file.files // 獲取filelist
},
// 上傳
uploadFile () {
let formData = new window.FormData()
for (let i = 0; i < this.fileList.length; i++) { // 每個file append到formdata裏
formData.append('file', this.fileList[i])
}
let url = Vue.prototype.API_URL + '/imageCompare'
axios({
method: 'post',
url: url,
data: formData,
headers: {'Content-Type': 'multipart/form-data'}
}).then(function (res) {
})
},