用html5自带的input file="",纯html5,不涉及到js就可以实现
<p>
<label>image</label>
<input type="file" accept="image/*" capture="camera" />
</p>
<p>
<label>video</label>
<input type="file" accept="video/*" capture="camcorder" />
</p>
<p>
<label>audio</label>
<input type="file" accept="audio/*" capture="microphone" />
</p>
capture表示,可以捕获到系统默认的设备,
比如: camera - 照相机
camcorder - 摄像机
microphone - 录音
accept表示,直接打开系统文件目录。
<input type="file" accept="image/*" multiple />
其实html5的input:file还支持一个multiple属性,表示可以支持多选
加上这个multiple后,capture就没啥用了,因为multiple是专门用来支持多选的