日期:2014-05-17  浏览次数:20735 次

struts2 上传.apk和.ipa文件
struts2 怎么  上传.apk和.ipa文件?急急急、。。。
------解决方案--------------------
       private String uname;
//单个的文件上传
private File resume;
private String resumeFileName;//文件的名字
//多个文件的上传
private File[] photo;
private String[] photoFileName;
public String execute() throws Exception {
System.out.println("UserAction.execute(-----------------): "+ new Date().toLocaleString());
ServletContext servletContext = ServletActionContext.getServletContext();
String realpath = servletContext.getRealPath("upload")+"/";
System.out.println("真实的路径----------"+ realpath);

//单个文件的上传
String fileType = resumeFileName.substring(resumeFileName.lastIndexOf("."));//截取文件名的后缀
FileUtils.copyFile(resume, new File(realpath+UUID.randomUUID()+fileType));//真实的路径  + 随机生成的数+ 文件名的后缀

//多个文件的上传
if(photo!=null&&photo.length>0){
for (int i = 0; i < photo.length; i++) {
String fileName = photoFileName[i];//获取多个文件的每一个文件的名字
System.out.println("UserAction.execute(------------------)"+fileName);
FileUtils.copyFile(photo[i], new File(realpath+UUID.randomUUID()+fileName.substring(fileName.lastIndexOf("."))));
}

}


return this.SUCCESS;
}