commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gaston Escobar" <gesco...@451.com>
Subject [fileupload] example code problem
Date Thu, 20 Feb 2003 21:17:24 GMT
I'm sorry for the last e-mail. It won't happen again.
I hope someone can still help me.
I write it again:


I've tried to use the FileUpload package I downloaded. But in the example
code, it throws an error when I try to compile it.
This is the example code that comes with the package:

    public void doPost(HttpServletRequest req, HttpServletResponse res)
    {
        FileUpload fu = new FileUpload();
        // 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.getFileName();
        // save comment and filename to database
        ...
        // write the file
        fi.write("/www/uploads/" + fileName);
    }


And this is the error my compiler throws:

UploadServlet.java:34: cannot resolve symbol
symbol  : method getFileName  ()
location: interface org.apache.commons.fileupload.FileItem
        String fileName = fi.getFileName();
                            ^
1 error

-----------------------

Please, help me. And in case this e-mail was not correctly posted here, tell
me where I could do that
Thank you very much


Mime
View raw message