<input type="file" /> android,图片无法显示在<input type =“file”> Android 4.0.4

我想用html上传图片,但总是失败。我通过console.log进行检查,并生成以下消息。图片无法显示在 Android 4.0.4

07-31 19:09:07.071: I/Web Console(16417): size:66797 at file:///android_asset/www/index.html:18

07-31 19:09:07.091: I/Web Console(16417): lastModifiedDate:Tue Jul 30 2013 03:44:18 GMT+0700 (WIT) at file:///android_asset/www/index.html:18

07-31 19:09:07.101: I/Web Console(16417): fileSize:66797 at file:///android_asset/www/index.html:18

07-31 19:09:07.111: I/Web Console(16417): name:1375130658314.jpg at file:///android_asset/www/index.html:18

07-31 19:09:07.121: I/Web Console(16417): type: at file:///android_asset/www/index.html:18

07-31 19:09:07.121: I/Web Console(16417): fileName:1375130658314.jpg at file:///android_asset/www/index.html:18

07-31 19:09:07.121: I/Web Console(16417): webkitSlice:function webkitSlice() { [native code] } at file:///android_asset/www/index.html:18

我发现“type”属性是空的。它发生在Android 4.0.4。

但4.1.2和4.1.3是可以的。

这个问题有什么线索吗?

-

Image preview example

oFReader = new FileReader(),

rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;

oFReader.onload = function (oFREvent) {

document.getElementById('preview').src = oFREvent.target.result;

};

function loadImageFile() {

if (document.getElementById("uploadImage").files.length === 0) { return; }

var oFile = document.getElementById("uploadImage").files[0];

for(var x in oFile)

console.log(x+":"+oFile[x]);

oFReader.readAsDataURL(oFile);

}

Image preview

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果您想在 Struts2 项目中将 javax 包替换为 jakartaee 包,可以按照以下步骤进行操作: 1. 在 pom.xml 文件中,将 struts2-core 的版本号修改为 2.5.26 或更高版本,以支持 jakartaee 包。同时,将 struts2-convention-plugin 和 struts2-junit-plugin 的版本号也修改为相应的版本: ``` <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.5.26</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-convention-plugin</artifactId> <version>2.5.26</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-junit-plugin</artifactId> <version>2.5.26</version> <scope>test</scope> </dependency> ``` 2. 在 pom.xml 文件中,排除 javax 包的依赖,添加 jakartaee 包的依赖,例如: ``` <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> ``` 修改为: ``` <dependency> <groupId>jakarta.servlet</groupId> <artifactId>jakarta.servlet-api</artifactId> <version>4.0.4</version> <scope>provided</scope> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> </exclusions> </dependency> ``` 3. 在 pom.xml 文件中,使用 Maven 依赖插件(maven-dependency-plugin)将本地仓库中的 javax 包替换为 jakartaee 包: ``` <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.1.2</version> <executions> <execution> <id>replace-javax-with-jakarta</id> <phase>process-resources</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.glassfish.jakartaee</groupId> <artifactId>jakartaee-api</artifactId> <version>8.0.0</version> <type>jar</type> <overWrite>true</overWrite> <outputDirectory>${project.build.directory}/classes</outputDirectory> <includes>javax/**</includes> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 这样,就可以将 Struts2 项目中的 javax 包替换为 jakartaee 包。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值