如何从HTML页面打开手机摄像头? [英] How to open phone camera from HTML page?
问题描述
我的android手机通过webview连接到Web服务器.在我的HTML中,我有一个按钮可以上传照片.用户应该可以选择上传图片或从相机拍摄照片. 我的HTML代码是:
my android phone is connected to a web server through a webview. in my HTML I have a button to upload a photo. the user should have the choice to upload an image or take a photo from camera. my HTML code is:
<div class="takePhoto">
<form id="take" action="" method="POST">
<input type="file" id= "cap" name="personalPhoto" accept="image/*" capture ="camera" id="camera"><p>
</form>
</div>
但是,当我单击按钮时,文件选择器将打开,并且我可以选择图像而不使用相机.有什么解决办法吗?
However when I click on the button the file chooser opens and I have the ability to choose images but not to use the camera. Any solution for this?
P.S.在我的代码中,单词(捕获)没有特殊的样式或颜色,我觉得很奇怪,这可能就是问题所在!
P.S. in my code the word (capture) doesn't have a special style or color which I find weird and this might be the problem!
推荐答案
在iPhone iOS6和更高版本的Android ICS中,HTML5具有以下标记,可让您从设备上拍照:
In iPhone iOS6 and from Android ICS onwards, HTML5 has the following tag which allows you to take pictures from your device:
<input type="file" accept="image/*" capture="camera">
您也可以尝试
<input type="file" accept="image/*" capture="capture">
或
<input type="file" accept="image/*;capture=camera">
这篇关于如何从HTML页面打开手机摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!