三星手机使用type="file"上传文件的问题
Posted by quentin 在 Sunday, 13 April 2014
使用HTML5进行手机应用开发时,遇到上传文件使用:
<input type="file" name="file" />
这个file类型在IOS以及Android一般手机里都没有问题,唯独在三星的系列手机内有问题。问题描述如下:
点击上传按钮->选择图片,结果整个表单页面重新刷新,导致表单内的所有填写的内容丢失,包括选择文件项本身。
一开始以为是三星不支持type="file",但是后来觉得没道理。连难搞定的IOS都能支持了,并且本身Android是支持的,三星不至于不支持。
后来才发现需要在标签内加入 accpet="image/*" 属性。
- 如:<input type="file" accept="image/*" >
- 另外也可以加上capture属性,标识通过什么选择。
- 如:
- <input type="file" accept="image/*" capture="camera">
- <input type="file" accept="video/*" capture="camcorder">
- <input type="file" accept="audio/*" capture="microphone">
参考链接:http://samsungapps.csdn.net/text.html?arcid=2810317
博客分类:
添加新评论