[英]How to set the upload size in apache commons upload
嗨,我正在使用apache commons upload上传文件
File file=this.getFile();//getter method for the file
String fileName="test.zip";
File target=new File("D:\\test",target);
FileUtils.copyFile(file,target);
但是与此同时,我最多只能上传20MB。如何在此代码中设置上传文件的大小。
这在文档中 。 您所要做的就是致电:
// 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);
以上是通过链接提供的示例代码。 但是,我不知道的FileUtils
类内的Apache共享上传 ,我怀疑你实际上可能是在谈论一个不同的库.. 有一类叫做文件实用程序在共享IO看起来像它涉及到您的代码示例一点点更好,您是否有机会谈论Commons IO并复制文件而不是上传文件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.