手机网页调用相机拍照或者图库

时间:2022-05-10
本文章向大家介绍手机网页调用相机拍照或者图库,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
<!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之后不会调用图库。

其中还有一个属性multiple,支持多选,当支持多选时,就需要可以选择图库功能,则不需要加capture,

所以只用写成:<input type="file" accept="image/*" multiple>就可以,可以在手机上测试一下。

参考链接:http://blog.csdn.net/zhihua_w/article/details/78125622