移动端利用input type=“file”照相和选择本地文件的兼容性问题
最新推荐文章于 2025-08-25 08:15:00 发布
原创 于 2018-11-28 15:33:58 发布 · 2w 阅读
· 2
· 4 ·
CC 4.0 BY-SA版权
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
<input type="file" accept="image/*" capture="camera">
<input type="file" accept="video/*" capture="camcorder">
<input type="file" accept="audio/*" capture="microphone">
/*
accept规定可通过文件上传控件提交的文件类型;
capture表示的是系统所捕获的默认设备,camera:照相机;camcorder:摄像机;microphone:录音。
*/
<input type="file" accept="image/*" >
<input type="file" accept="video/*" >
<input type="file" accept="audio/*" >
/*
如果不加上capture,则只会显示相应的,例如上述三种依次是:拍照或图库,录像或图库,
录像或拍照或图库,加上capture之后不会调用图库。
其中还有一个属性multiple,支持多选,当支持多选时,multiple优先级高于capture,
所以只用写成:<input type="file" accept="image/*" multiple>就可以
*/
手机浏览器的话大部分都是支持的 (不支持的浏览器暂时无法就行兼容处理,只能想其他办法)
微信中ios内置的浏览器是完全支持的
android中必须加上accept最好也加上capture
如果是做跨平台应用,在webView中是不能用的,应该调用插件运用原生去实现。
相关知识
input[type=file] 获取上传文件的内容
input type=“file“属性详解,利用capture调用手机摄像头
onclick触发type=file并上传文件
input[type=“file”] change事件第二次不触发
使input type=“file” 不可编辑
美化input type=“file”的样式
HTML input 标签的 所有type 属性及用法
自定义(滑动条)input[type=“range”]样式
h5页面含input type=file,安卓webview嵌入时不能调起文件选择功能
前端——table标签和form标签和控件:table,input的type类型,select和option,label,textarea
原文链接: 移动端利用input type=“file”照相和选择本地文件的兼容性问题 https://m.huajiangbk.com/newsview2389949.html
| 上一篇: 教你一招:挑选苹果的方法! | 下一篇: 苹果新鲜度与脆度挑选秘诀,老果农... |



