You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/08/21 23:12:26 UTC
DO NOT REPLY [Bug 22643] New: -
Java docs bug
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22643>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22643
Java docs bug
Summary: Java docs bug
Product: Commons
Version: 1.0 Alpha
Platform: PC
URL: http://jakarta.apache.org/commons/fileupload/apidocs/ind
ex.html
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: File Upload
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: pjlmas@yahoo.com
You have published this code in the javadocs main page of the FileUpload and
the last line of the code isn't right "fi.write("/www/uploads/" + fileName);"
because the method write() doesn't accept Strings as parameters. Bye and thanks
for the excelent library that you are sharing.
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
DiskFileUpload fu = new DiskFileUpload();
// maximum size before a FileUploadException will be thrown
fu.setSizeMax(1000000);
// maximum size that will be stored in memory
fu.setSizeThreshold(4096);
// the location for saving data that is larger than getSizeThreshold()
fu.setRepositoryPath("/tmp");
List fileItems = fu.parseRequest(req);
// assume we know there are two files. The first file is a small
// text file, the second is unknown and is written to a file on
// the server
Iterator i = fileItems.iterator();
String comment = ((FileItem)i.next()).getString();
FileItem fi = (FileItem)i.next();
// filename on the client
String fileName = fi.getName();
// save comment and filename to database
...
// write the file
fi.write("/www/uploads/" + fileName);
}