Domanda

Hi am using apache commons upload for uploading files

   File file=this.getFile();//getter method for the file
   String fileName="test.zip";
   File target=new File("D:\\test",target);
   FileUtils.copyFile(file,target);

But with this i can upload only upto 20MB.how can i set the size for the uploaded files in this code.

È stato utile?

Soluzione

This is in the documentation. All you have to do is call:

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);

// Set overall request size constraint
upload.setSizeMax(yourMaxRequestSize);

// Parse the request
List /* FileItem */ items = upload.parseRequest(request);

The above is from sample code available via the link. However, I don't know of a FileUtils class within Apache Commons Upload, and I suspect you may actually be talking about a different library.. There is a class called FileUtils in Commons IO which looks like it relates to your code sample a little better, were you by any chance talking about Commons IO and copying a file, rather than uploading one?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top