jsp代码
<input name="cmpPic" class="{validate:{required:true,accept:'bmp?|jpg|gif|png'}}" type="file"/>java代码 String path=ServletActionContext.getServletContext().getRealPath("/company_image");
File cmpPicSrc= new File(company.getCmpPic());
String newFileName=company.getCmpId()+"_"+System.currentTimeMillis()+".jpg";
File cmpPicDest= new File(path,newFileName);
FileUtils.copyFile(cmpPicSrc, cmpPicDest);为什么cmpPicSrc的后最是tmp啊,我上传的是个png 文件啊
<input name="cmpPic" class="{validate:{required:true,accept:'bmp?|jpg|gif|png'}}" type="file"/>java代码 String path=ServletActionContext.getServletContext().getRealPath("/company_image");
File cmpPicSrc= new File(company.getCmpPic());
String newFileName=company.getCmpId()+"_"+System.currentTimeMillis()+".jpg";
File cmpPicDest= new File(path,newFileName);
FileUtils.copyFile(cmpPicSrc, cmpPicDest);为什么cmpPicSrc的后最是tmp啊,我上传的是个png 文件啊
解决方案 »
- java.lang.NoSuchMethodError: javax.persistence.OneToOne.orphanRemoval()Z
- Hibernate可以直接访问public,private和protected的访问方法和field
- S2SH整合错误请指教
- cxf webservice client error,急急急急!!
- 新手在学习spring hibernate整合时碰到问题!
- 请问一个jcreator j2ee配置的问题?
- 谁做过建行网上支付(他们给的资料都是JAVA的)..本人没用过JAVA,在配置安装程序时遇到问题....求救..........
- j2ee是否包括j2se
- 问题:用JB9发布bookstore到weblogic700出现提示?
- 权限管理模块面试题
- Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Leve
- hibernate的session.get()方法到底会不会查二级缓存?
int pos = fileName.lastIndexOf( "." );
return fileName.substring(pos);
}
直接截取就可以了
int pos = fileName.lastIndexOf( "." );
return fileName.substring(pos);
}
直接截取就可以了
int pos = fileName.lastIndexOf( "." );
return fileName.substring(pos);
}
直接截取就可以了
private File url;
private String urlContentType; // 上传文件类型
private String urlFileName; // 上传文件的真实名字
三个属性,且action必须实现一个ServletResponseAware
String fileEx = urlFileName.substring(urlFileName.indexOf("."),
urlFileName.length());
可以获取文件后缀
服务器端直接substring
int pos = fileName.lastIndexOf( "." );
return fileName.substring(pos);
}
直接截取就可以了
哥 我不用 struts 的<s:file>标签 fileName哪里来?,
但是在action中获取还是用这个 哈哈 支持