input file禁用手机本地文件选择,只允许拍照上传图片 capture="camera"

时间:2020-07-01 09:20:43   收藏:0   阅读:422
<input type="file" accept="image/*" capture="camera">

<input type="file" accept="video/*" capture="camcorder">
 
<input type="file" accept="audio/*" capture="microphone">

## 在webapp上使用input:file, 指定capture属性调用默认相机,摄像,录音功能

在iOS6下开发webapp,使用inputz之file,很有用

capture表示,可以捕获到系统默认的设备,比如:camera--照相机;camcorder--摄像机;microphone--录音。

accept表示,直接打开系统文件目录。

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

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

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

 

手机浏览器的话大部分都是支持的 (不支持的浏览器暂时无法就行兼容处理,只能想其他办法)

微信中ios内置的浏览器是完全支持的

android中必须加上accept最好也加上capture

如果是做跨平台应用,在webView中是不能用的,应该调用插件运用原生去实现。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!