input file
IOS
- 在IOS webview中,上传大图时,change事件触发很慢,(业务场景 : 开发IOS APP的H5页面,意见反馈,涉及到图片上传,可是发现上传小图很快触发change事件, 上传大图(7M)时等了约5S 才触发change事件), UC中也是如此。-----未找到原因
Andriod
- 在Andriod webview中,可能是Andriod系统出于安全性的考虑,禁止了input file上传文件。所以在做app的H5页面时,input file是无效的。一般用Andriod原生的方案去解决。
微信
微信公众号站点开发时,我们可能会给input file设置这样的accept
<input type="file" accept="image/jpg,image/jpeg,image/png,image/gif,image/bmp "/>
这样设置的话在多数Andriod手机中(比如荣耀6plus,三星note系列,小米3手机等,其他的没测),会出现只有选择照片,没有拍照,此时我们可以更改下accept:
<input type="file" accpet="image/*" />
经测试,accept 更改为 image/* 的话,在荣耀6plus,三星note5中,点击input file会有拍照的选项,但小米3手机还是没有拍照,可能是与系统有关吧。-----未找到原因
在有的手机浏览器中,添加 capture 属性是可以直接唤起相关应用的,不过兼容性有较大问题,如:
<input type="file" capture="camera"/> ---照相机 <input type="file" capture="camcorder"/> ---摄像机 <input type="file" capture="microphon"/> ---录音机