> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Sunday, April 04, 2004 5:35 PM > To: [EMAIL PROTECTED] > Subject: Newbie Commons Upload Servlet Won't Compile > > > > Here is my code please help figure out what is wrong...
This is actually a question for the commons-user list rather than the commons-dev list, since you are using FileUpload rather than developing it. Did you look at the documentation? The Javadocs would show you that the write() method takes a File instance rather than a String, and the user guide shows an example of how to use it. http://jakarta.apache.org/commons/fileupload/ -- Martin Cooper > > ------------------------------------------------------------------ > ------------ > ------------------------- > import java.io.*; > import java.util.*; > import javax.servlet.*; > import javax.servlet.http.*; > import org.apache.commons.fileupload.*; > > > public class fileuploadcommon extends HttpServlet { > > public void doPost(HttpServletRequest req, > HttpServletResponse res) > throws ServletException, IOException > > { > 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("/uploads/" + fileName); > > } > } > ------------------------------------------------------------------ > ------------ > ------------------------- > Here is the error that I get... > ------------------------------------------------------------------ > ------------ > ------------------------- > > fileuploadcommon.java:47: write(java.io.File) in > org.apache.commons.fileupload.FileItem > > cannot be applied to (java.lang.String) > > fi.write("/uploads/" + fileName); > ^ > 1 error > ------------------------------------------------------------------ > ------------ > ------------------------- > > I can't figure out what this means. If anyone knows what this > error is cause > by please post. > Thank you, > Matt Newman > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]