In html/js, when you select a file on Chrome (43) for Android (5.1.1), the resulting files name is missing the extension and the file type is an empty string. Wondering if there is way to get the missing information? And if not, is there a reasonable way to do clientside side validation on file types?
Please see the example fiddle below and note that I get extension and mime type on windows desktop browsers and ios safari.
$(function(){
$("#fileInput").on("change", function(e){
$("#name").html(e.target.files[0].name);
$("#type").html(e.target.files[0].type);
});
});
Update I noticed when using the android Documents browser, the Audio tab (which I was using to select files) does not seem to supply file extension and mime type. If I navigate to files using any other tab, everything seems ok.
Via the android Documents file browser, some of the tabs do not provide file extension and type. The Audio tab (which displays audio metadata) and some of the connected storage accounts for example.
As such, another way to do file type validation is to use "file signatures" http://www.filesignatures.net/index.php?page=all
Essentially you take a look at a portion of the binary file. Simplified example below.