I am attempting to grab the file/mime type of a file when it is being added to a basic HTML file input.
My basic HTML:
<form method="post" enctype="multipart/form-data">
<div>
<label for="file">Upload an MKV file:</label>
<input type="file" id="file" name="file" multiple>
</div>
</form>
My Javascript:
var control = document.getElementById("file");
control.addEventListener("change", function(event) {
var files = control.files;
for (var i = 0; i < files.length; i++) {
console.log("Filename: " + files[i].name);
console.log("Type: " + files[i].type);
}
}, false);
When adding a MP4 for example, the following is output to the console:
Filename: myvideo.mp4
Type: video/mp4
Although when adding a MKV file, the console outputs that the type is empty, like so:
Filename: myvideo.mkv
Type:
After further research, I found that the official mimetype of an MKV file is video/x-matroska. So I tried adding accept="video/*" to the file input. This allows all video types to be added to the input besides MKV files, which is very odd.
So why is my file input unable to detect the file type of MKV files?