Warning: file_get_contents(http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=site:linuxpk.com%20SmartUpload%D4%DAservlet%D6%D0%CA%B9%D3%C3%B7%BD%B7%A8&rsz=large) [function.file-get-contents]: failed to open stream: HTTP request failed! in /opt/linuxpk/doc.linuxpk.com/article.php on line 110
正文 - SmartUpload在servlet中使用方法 - Linux文库
this is a extra element for clear the floated element
SmartUpload在servlet中使用方法
  • 12/31
  • 2008
Servlet/JSP | Java 3512 次查看
  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());

  }