开发微信端浏览器访问的HTML5的页面,页面中有一个<input id="input" type="file"/>标签,iOS直接就支持吊起相机拍照或是相册选择,html
但android中不支持吊起相机拍照,只能吊起相册选择,网上的帖子说是由于android屏蔽了文件上传功能仍是怎么的,没看明白。android
此篇博文记录如何解决这一问题,使得android也能够直接吊起相机拍照。浏览器
在查资料的以后,总结了一下用input调用相机和相册功能的方法,以前没有深刻了解过,如今整理一下:微信
不须要特殊环境,使用input标签 type值为file,能够调用系统默认的照相机、相册、摄像机、录音功能。先上代码:ide
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML5页面如何在手机端浏览器调用相机、相册功能</title>
</head>
<body>
<div>
<input type="file" accept="image/*" capture="camera">
<input type="file" accept="video/*" capture="camcorder">
<input type="file" accept="audio/*" capture="microphone">
</div>
</body>
</html>
accept表示打开的系统文件目录;
capture表示的是系统所捕获的默认设备,camera:照相机;camcorder:摄像机;microphone:录音。测试
若是不加上capture,则只会显示相应的,例如上述三种依次是:拍照或图库,录像或图库,录像或拍照或图库,加上capture以后不会调用图库。spa
其中还有一个属性multiple,支持多选,当支持多选时,multiple优先级高于capture,.net
因此只用写成:<input type="file" accept="image/*" multiple>就能够,能够在手机上测试一下。code
原文地址:https://blog.csdn.net/Zhihua_W/article/details/78125622htm