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

0

11

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

Abutment answered 25/10, 2021 at 15:56 Comment(4)
.type: "On getting, user agents must return the type of a Blob as an ASCII-encoded string in lower case, such that when it is converted to a byte sequence, it is a parsable MIME type, or the empty string – 0 bytes – if the type cannot be determined."Highjack
So HEIC/HEIF files don't have a parsable MIME type?Abutment
I'm still wondering Why this isDisrespect
It have the correct type in mac that is "image/heif", but in windows it is ''Clavicembalo

© 2022 - 2024 — McMap. All rights reserved.