I have the html file input:
<input type='file' id='upload' accept='audio/*' onchange='getFileType(this);return false;' />
And javascript function:
function getFileType(fl){
var fileExt = "." + fl.value.match(/\.([^\.]+)$/)[1];
alert(fileExt);
}
It works good, but if operating system is configured to hide known mime types so file extension is missing. And fl.value.match(/\.([^\.]+)$/)[1]
is crushes on null[1]
- "Cannot read property '1' of null".
So how I can get file extension on this case? I need cross browsers solution.