码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2020-07-01 09:20:43      阅读:422      评论:0      收藏:0      [点我收藏+]

标签:使用   code   其他   相机   type   and   本地   允许   多选   

<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中是不能用的,应该调用插件运用原生去实现。

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

标签:使用   code   其他   相机   type   and   本地   允许   多选   

原文地址:https://www.cnblogs.com/mica/p/13217360.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!