I have input(type="file") on a web page.
<input type='file' name="file" accept="image/*" />
I use jQuery to capture the file as follows:
$('input').on('change', function(e) { console.log(e.target.files[0]); });
I need to check if e.target.files[0].type pattern "image.*" , So I do: var matches = e.target.files[0].type.match('image.*');
This works fine in most cases, but when the application launches from its own Android browser, e.target.files[0].type is an empty string. This happens if I select an image stored on the device. If I take an image with the camera e.target.files[0].type , this is "image/jpeg" .
Has anyone encountered this problem before?
source share