2007-04-03
是用SmartUpload进行文件上传
package com.jamesby.file.servlet;
public class UpLoadServlet extends HttpServlet {
private static Log log = LogFactory.getLog(UpLoadServlet.class);
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
}
final public ServletConfig getServletConfig() {
return config;
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
try {
SmartUpload su = new SmartUpload();
su.initialize(config, request, response);
su.setMaxFileSize(1024 * 1024 * 4); //4M
su.upload();
String paramValue = su.getRequest().getParameter("paramName");
String path = "d:/upload";
for (int i = 0; i < su.getFiles().getCount(); i++) {
com.jspsmart.upload.File file = su.getFiles().getFile(i);
String fileName = file.getFileName();
if (!file.isMissing()) file.saveAs(path + "/"+fileName,SmartUpload.SAVE_PHYSICAL);
else continue;
}
return null;
} catch (Exception ex) {
}
}
}
发表评论
- 浏览: 129509 次
- 性别:


- 详细资料
搜索本博客
最近加入圈子
最新评论
-
iBatis学习小结
感谢辛勤劳动,希望能贡献更好的东西 :
-- by xuguangyun -
为什么我的Spring的声明事 ...
不要自己抛异常,spring不知道那是什么异常,在catch中直接抛出原来的异常 ...
-- by sinoalex -
Spring AOP 学习小结
写得非常好! 关于 AOP 的几个基础概念,我感觉Spring 的参考文档上面 ...
-- by Hejrcc -
Spring AOP 部分Class的 ...
是的,通过UML的类图,从整体上面了解类之间的关系,是一种不错的方式,理清类之间 ...
-- by rainlife -
Spring AOP 部分Class的 ...
感谢共享
-- by wangzhongjie






评论排行榜