Liny_@NotePad

沉迷ACG中

使用oreilly的MultipartRequest上传文件

随便写个上传的表单(enctype="multipart/form-data"),servlet这么写~

  1.         private String path = "/Upload/";
  2.  
  3.         protected void doPost(HttpServletRequest request, HttpServletResponse response)
  4.                         throws ServletException, IOException {
  5.  
  6.                 int maxPostSize = 5 * 1024 * 1024 ;
  7.                
  8.                 MultipartRequest multi = new MultipartRequest(request, getServletContext().getRealPath("/")+ path ,maxPostSize,"GBK");
  9.                
  10.                 response.sendRedirect("index.jsp");
  11.         }

即可 - -