commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gustavo N." <gusnes_mailingl...@yahoo.com.ar>
Subject Re: [fileupload] example code problem
Date Thu, 20 Feb 2003 21:41:54 GMT
Hi Gaston,
    I think the example has an error,  you can get the "filename on the
client" with the method  "getName()". That say's the documentation that
comes with the package.-

        I hope this help you.-

                                Gustavo.-








----- Original Message -----
From: "Gaston Escobar" <gescobar@451.com>
To: <commons-user@jakarta.apache.org>
Sent: Thursday, February 20, 2003 6:17 PM
Subject: [fileupload] example code problem


> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org

------------
¡Internet GRATIS es Yahoo! Conexión!
Usuario "yahoo", contraseña "yahoo". 
Desde Buenos Aires, 4004-1010.
Otras ciudades: http://conexion.yahoo.com.ar/avanzados.html

Mime
View raw message