三星手机使用type="file"上传文件的问题

使用HTML5进行手机应用开发时,遇到上传文件使用:
 <input type="file" name="file" />

这个file类型在IOS以及Android一般手机里都没有问题,唯独在三星的系列手机内有问题。问题描述如下:
点击上传按钮->选择图片,结果整个表单页面重新刷新,导致表单内的所有填写的内容丢失,包括选择文件项本身。

 

一开始以为是三星不支持type="file",但是后来觉得没道理。连难搞定的IOS都能支持了,并且本身Android是支持的,三星不至于不支持。

后来才发现需要在标签内加入 accpet="image/*" 属性。

  1. 如:<input type="file" accept="image/*" > 
  2. 另外也可以加上capture属性,标识通过什么选择。
  3. 如:
  4. <input type="file" accept="image/*" capture="camera"> 
  1. <input type="file" accept="video/*" capture="camcorder"> 
  2. <input type="file" accept="audio/*" capture="microphone"> 

 

参考链接:http://samsungapps.csdn.net/text.html?arcid=2810317

 

博客分类: 
You voted 5. Total votes: 2150

添加新评论