上传文件(1)

阅读更多

用jspSmartUpload组件

jspSmartUpload.jar,在smartupload\WebRoot下新建upload文件夹-----用来存放上传的文件

ServletConfig config = getServletConfig();
 // 新建一个SmartUpload对象
  SmartUpload su = new SmartUpload();
  // 上传初始化
  su.initialize(config,request,response);
  su.setMaxFileSize(2000*2000);  	
  su.setAllowedFilesList("jpg,txt,png");
try {
      su.upload();
      int count = su.save("/upload");   			
      String fileName = su.getFiles().getFile(0).getFileName();//文件名
      String fileExt = su.getFiles().getFile(0).getFileExt();//文件扩展名
      String filePathName =    su.getFiles().getFile(0).getFilePathName();//文件全名
      com.jspsmart.upload.File file = su.getFiles().getFile(0);

 可以将图片名字存到数据库中,上面这个是对单个图片的上传与修改

用jspSmartupload实现多文件上传

http://blog.sina.com.cn/s/blog_6814a1510100nedb.html

 

你可能感兴趣的:(上传文件(1))