【html】手机web端上传图片


1)上传文件直接用h5中的<input type="file" >

2)调用手机摄像头上传图片则是:

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

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

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

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

 针对 2)直接调用手机的拍照功能,对于安卓系统的某些内置浏览器限制 是无法获取成功的(andriod webview考虑安全原因屏蔽了,<input type="file" />这个功能)

      解决方案:重写webview的WebChromeClient(非前端可操作)

参考资料:

http://blog.csdn.net/huangwenkui1990/article/details/51967464

http://blog.csdn.net/hvkcoder/article/details/51365191

http://www.jianshu.com/p/48e688ce801f

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM