html5调用手机摄像头

805 阅读1分钟
<input type="file" accept="image/*" capture="camera">\
<input type="file" accept="video/*" capture="camcorder">\
<input type="file" accept="audio/*" capture="microphone">

capture表示,可以捕获到系统默认的设备,比如:camera--照相机;camcorder--摄像机;microphone--录音。
accept表示,直接打开系统文件目录。

其实html5的input:file标签还支持一个multiple属性,表示可以支持多选,如:

<input type="file" accept="image/*" multiple>

限制只能选择图片

<input type="file" accept="image/*">  

限制只能选择视频

<input type="file" accept="video/*">  

限制只能选择音频

<input type="file" accept="audio/*">  

直接打开摄像头拍照

<input type="file" accept="image/*" capture="camera"> 

直接打开摄像头录像

<input type="file" accept="video/*" capture="camera">  

原:www.cnblogs.com/hss-blog/p/…