Why do HEIC/HEIF files have a blank file type in a FileList?

1.2k Views Asked by At

I'm using the file select input to upload multiple files. After a user selects their files, I'm sorting through the FileList in a loop to check if there are any HEIC/HEIF files, so I can display an error message.

const fileSelect = document.createElement("input");
fileSelect.setAttribute("type", "file");
fileSelect.setAttribute("multiple", "multiple");
fileSelect.click();
if(!this.vm.acceptedTypes.includes(file.type)) {
  console.log(file);
  this._$inj.globalFac.showAlert(file.name, `Error: File type ${file.type} is not supported.`);
  continue;
}

However, when a user uploads a HEIC/HEIF file, the type property is blank. Why?

File Object with blank type

0

There are 0 best solutions below