input type=file 怎么样调取用户手机照相机

input 有个属性accept="image/*" 这样就可以了,同时在网上看到了其他答案,试了下没啥效果。写记录下来

如下:

  1. 使用input:file标签, 去调用系统默认相机,摄像,录音功能,其实是有个capture属性,直接说明需要调用什么功能

    <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表示,直接打开系统文件目录。

  2. 2

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

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

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

猜你喜欢

转载自www.cnblogs.com/SofuBlue/p/11388733.html