vue-upload-component
vue-upload-component copied to clipboard
File type is empty for .doc and .docx
I'm using the Vue 3 version. Whenever I try to upload a .doc .docx file the newFile.type is empty, therefore I'm not able to validate on inputFilter
I'm aware that I can check file type as per filename as explained in docs, but it doesn't fill very trustworthy. Instead, I'd like to check with file type as I use to do with any other file (which works as expected)
The odd thing is that .xls and .xlsx files work fine returning this in newFile.type:
.xlsx => type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
.xls => type: "application/vnd.ms-excel"
Any advice will be appreciated
const inputFilter = (newFile, oldFile, prevent) => {
console.log(newFile, oldFile)
// Handle new file
if (newFile && !oldFile) {
// Check valid extension
if (!accept.includes(newFile.type)) {
alert('Tipo de archivo no valido')
return prevent()
}
}
}
The log returns this
{
active: false
data: {}
error: ""
file: File
lastModified: 1657148890308
lastModifiedDate: Wed Jul 06 2022 20:08:10 GMT-0300 (Argentina Standard Time) {}
name: "IMBATIBLE 2019 CICLO SUPERIOR Cs Sociales.doc"
size: 93184
type: ""
webkitRelativePath: ""
fileObject: true
headers: {...}
id: "9716pv89zvt"
name: "IMBATIBLE 2019 CICLO SUPERIOR Cs Sociales.doc"
postAction: "http://api.foobar.test/files"
progress: "0.00"
putAction: undefined
response: {}
size: 93184
speed: 0
success: false
timeout: 0
type: ""
}