You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by robert burrell donkin <ro...@blueyonder.co.uk> on 2003/02/20 21:43:37 UTC

[fileupload] example code problem [WAS URGENT PROBLEM]

hi Gaston

this is the right list but since it's for a number of components, the 
convention is that you prefix your email with the component name. you 
should also probably choose a better subject. for more details please read 
httpL//jakarta.apache.org/site/mail.html and the mailing guidelines for 
this list.

as far as your problem goes, the only thing i can think of is that you 
have an old version of fileupload in your classpath. maybe some other 
people will be able to give you a better answer.

- robert

On Thursday, February 20, 2003, at 08:26 PM, Gaston Escobar wrote:

>
> I don't really know where to post this e-mail. I'm sorry in case I've 
> made a
> mistake.
> 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
>