Mobile Technologies Mobile Computing . 1 year ago

(JS) For , determine if the device offers or not to capture a photo from the camera

(JS) For <input type=“file”>, determine if the device offers or not to capture a photo from the camera

0 views   0   0 likes   0 shares Tuteehub forum manpreet 0 answers
_x000D_ _x000D_ When uploading a file, I need to give the user the possibility: upload the file from the file-system capture a photo from the camera Simply using input type="file", that behavior is implemented by most of the browser-devices pairs, but not by all of them (see that answer for details: https://stackoverflow.com/a/33414310). Those pairs that don't implement the photo capture are probably only about computer devices, but I'm not 100% sure of that (maybe some browsers on computer devices do implement the photo capture, maybe some browsers on non-computer devices don't). To make up for that lack on such devices, I use a library to have: one input type="file" to upload file from file-system, + for certain devices: to capture file from camera one special button calling the library to capture photo That library fulffils others tasks and is nicely integrated to my upload system. Also, I use it for a long time now, so to change it might introduce regressions. To conclude: I would prefer to keep it. On the other hand, for devices that allow the photo capture, that library performs less than the device photo capture. For example, it does not offer the possibility to switch between front and back cameras. That's why, to capture photos, I need to use that library only for devices that don't implement the photo capture. In other words: I need to determine if a device implements or not the photo capture via input type="file" I found many many answers to determine if the browser is mobile or not, but no one is satisfying. The most interesting thread was: How to test if the browser support . Unfortunately, that solution is not perfect: it's not because the "capture" property is not available for an input element, that the browser and the device does not offer the possibility to capture a photo via the input element. It only means that it's not possible to force capturing a photo from the camera instead of uploading a file from the filesystem. But it does not mean the capture from the camera is not possible. However, after reading documentations I found it's highly related... ...but after some tests, I found a counter-exemple: on a Samsung tablet, Firefox tells me the "capture" property is not available for input, but the browser offers to capture a photo via the input element after all. Any help? :)
tuteehub_quiz
Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

profilepic.png

Tuteehub forum answer Answers (0)


Related Tags