commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dakota Jack <>
Subject Re: [FileUpload] Getting wrong filename from FileItem
Date Wed, 04 May 2005 17:26:01 GMT
Some people think this is a bug and some people think that this is a
feature.  Martin, who makes all the decisions as a practical but not
as a theoretical (so please let's not debate this) matter on this has
decided it is a feature.  Since he seems to integrate his day job and
this work, that is not likely to change.  That is not to suggest there
is anything wrong but merely to advise you that you are not likely to
convince him this is a bug when it is integrated into his own work. 
That is not a problem, however.  I just went in and changed the
commons upload code adding .getName() to the file at this stage.  The
problem you are seeing is in Internet Explorer, right?  Firefox and
Netscape return the file name and Internet Explorer returns the full
path.  Anyway, you either have to solve the problem in the commons
upload code itself, where it is easy to solve, or to go through some
wasted mechanisms after the fact.  Everyone has to solve this problem
somewhere, so I definitely come down on the side of "bug" versus


On 5/4/05, Mihael Knezevic <> wrote:
> hi,
> i'm quite new to this project and perhaps i'm making some mistakes. perhaps
> you can help me.
> i'm trying to upload a file from a windows desktop to a linux server running
> tomcat 5.0.28.
> i'm using the following code to get a FileItem object:
> // create a new file upload handler
> ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
> // parse the request
> try
> {
>  List items = upload.parseRequest(request);
>  for (Iterator iter = items.iterator(); iter.hasNext();)
>  {
>   FileItem element = (FileItem);
> ...
> ...
> ...
> now when i use the element.getName() method i'm getting the full path (C:
> \mydir\myfile.txt) instead of just name of the file (myfile.txt). there is no
> problem if the client is also a linux client. has it to do with the different
> file separator characters?
> any help will be appreciated very much.
> thanx in advance
> mihael knezevic
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message