尝试上传压缩的多部分文件。写在特定的位置。但无法删除该文件。解压后..尝试使用fileObj.delete
但没有用!!
只是示例代码:
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setSizeThreshold(maxMemSize);
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setSizeMax(maxFileSize);
List fileItems = upload.parseRequest(request);
// Process the uploaded file items
Iterator i = fileItems.iterator();
while (i.hasNext())
{
FileItem fi = (FileItem) i.next();
if (!fi.isFormField())
{
fileName = FilenameUtils.getName(fi.getName());
String contentType = fi.getContentType();
long sizeInBytes = fi.getSize();
logger.info("File name is::"+fileName);
logger.info("content type is ::"+ contentType);
logger.info("size is::"+sizeInBytes);
// Write the file
fileObj = new File(dirObj, clientFileName+".zip");
fi.write(fileObj);
return fileObj;
答案 0 :(得分:0)
完成后,您必须关闭该文件。 Windows不允许删除打开的文件。