Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 513eb66

Browse files
authored
fix[UploadExcel]: add file type check (PanJiaChen#878)
1 parent 62e1c85 commit 513eb66

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/components/UploadExcel/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export default {
4141
return
4242
}
4343
const rawFile = files[0] // only use files[0]
44+
45+
if (!this.isExcel(rawFile)) {
46+
this.$message.error('Only supports upload .xlsx, .xls, .csv suffix files')
47+
return false
48+
}
4449
this.upload(rawFile)
4550
e.stopPropagation()
4651
e.preventDefault()
@@ -110,6 +115,9 @@ export default {
110115
headers.push(hdr)
111116
}
112117
return headers
118+
},
119+
isExcel(file) {
120+
return /\.(xlsx|xls|csv)$/.test(file.name)
113121
}
114122
}
115123
}

0 commit comments

Comments
 (0)