ServletFileUpload上的异常

时间:2015-03-17 17:33:30

标签: java servlets file-upload

情况:我正在上传一个包含几千条记录的文件。文件大小为100 kB,没有问题。但是,我在文件大小超过100 kB时会遇到异常。

问题:我在以下行收到例外:

List<DiskFileItem> items = upload.parseRequest(request);

我得到的例外是:

Error while processing multipart request:org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\DNDUtility\upload_tmp\upload_172408d6_14c27eae211__8000_00000001.tmp (The system cannot find the path specified) : Processing of multipart/form-data request failed. D:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\DNDUtility\upload_tmp\upload_172408d6_14c27eae211__8000_00000001.tmp (The system cannot find the path specified)

我甚至将ServletUpload.MaxFileSize()设置为1 MB。然而,如果我尝试上传超过100 kB的文件,我会遇到异常。

1 个答案:

答案 0 :(得分:2)

尝试此操作(将其设置为3MB):

ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(3000 * 1024, tmpDir));