@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("UTF-8");

        File cacheFile = new File(UPLOAD_CACHE_PATH);
        if (!cacheFile.exists()) {
            cacheFile.mkdir();
        }

        DiskFileItemFactory factory = new DiskFileItemFactory();
        factory.setSizeThreshold(8192 * 1024); // 设置缓冲区大小8MB
        factory.setRepository(cacheFile);// 设置缓冲区目录
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setHeaderEncoding("UTF-8");
        upload.setSizeMax(8192 * 1024 * 10);// 设置最大文件大小为40MB

        try {
            List<FileItem> fileItemList = upload.parseRequest(request);
            if (fileItemList != null) {

                for (FileItem item : fileItemList) {

                    if (item.isFormField()) {

                        String fileName = item.getName();
                        String uploadDir = FileUtil.createDefaultUploadDir();
                        if (!new File(uploadDir).exists())
                            new File(uploadDir).mkdirs();

                        File uploadFile = new File(uploadDir + fileName);
                        if (!uploadFile.exists())
                            uploadFile.createNewFile();

                        item.write(uploadFile);
                    }
                }
            }
        } catch (FileUploadException e) {
            logger.error(e);
            sendResponse("解析上传文件错误.", response);
        } catch (Exception e) {
            logger.error(e);
            sendResponse("上传文件错误.请联系管理员", response);
        }
    }