Subj: Newbie Commons Upload Servlet Won't Compile�
Date: 4/4/2004 5:35:13 PM Pacific Daylight Time
From: Artstar910
To: [EMAIL PROTECTED]
Here is my code please help figure out what is wrong...
------------------------------------------------------------------------------
-------------------------
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