日期:2014-05-17 浏览次数:20729 次
HttpServletRequest request= ServletActionContext.getRequest();
HttpServletResponse response= ServletActionContext.getResponse();
request.setCharacterEncoding("gb2312");
SmartUpload smart = new SmartUpload();
JspFactory jsp = null;
PageContext context = null;
jsp = JspFactory.getDefaultFactory();
context = jsp.getPageContext((Servlet) this, request, response, "", true, 8192, true);
smart.initialize(context); //上传初始化
smart.upload();
String pic1 = smart.getFiles().getFile(0).getFileName();//取得图片名称
smart.getFiles().getFile(0).saveAs("/photodescribe"+File.separator+pic1);//保存该图片
String pic2 = smart.getFiles().getFile(1).getFileName();
smart.getFiles().getFile(1).saveAs("/photodescribe"+File.separator+pic2);