zl程序教程

您现在的位置是:首页 >  前端

当前栏目

h5调用手机照相机

H5手机 调用
2023-09-11 14:15:30 时间

camera.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>camera相机调用</title>
</head>
<body>
    <input accept="image/*" type="file" capture="camera" name="file" accept=".gif,.jpg,.jpeg,.png">
    <input type="file" accept="image/*;capture=camera">
</body>
</html>

说明:

<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>

加上这个multiple后,capture就没啥用了,因为multiple是专门用来支持多选的。