服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

smartupload在servlet中使用方法


  smartupload mysmartupload = new smartupload();
  
  mysmartupload.initialize(servlet.getservletconfig(), request,response);
  
  // 设定上传限制
  
  // 1.限制每个上传文件的最大长度。
  
  // mysmartupload.setmaxfilesize(10000);
  
  // 2.限制总上传数据的长度。
  
  // mysmartupload.settotalmaxfilesize(20000);
  
  // 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。
  
  // mysmartupload.setallowedfileslist("doc,txt");
  
  // 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat, jsp,htm,html扩展名的文件和没有扩展名的文件。
  
  // mysmartupload.setdeniedfileslist("exe,bat,jsp,htm,html,,");
  
  mysmartupload.upload();
  
  //读取其它数据
  
  request req = mysmartupload.getrequest();
  
  string title = req.getparameter("title");
  
  //保存文件
  
  for (int i = 0; i < mysmartupload.getfiles().getcount(); i++) {
  
  com.jspsmart.upload.file file = mysmartupload.getfiles().getfile(i);
  
  if (file.ismissing()) continue;
  
  file.saveas(savepath + file.getfilename());
  
  }

扫描关注微信公众号