You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Martin Cooper <ma...@apache.org> on 2006/01/21 02:37:58 UTC

Re: [FileUpload] IE vs Firefox

First of all, please respect the conventions of this mailing list, and
prefix your subject with the name of the relevant component in square
brackets, as I have done with this reply. See:

http://jakarta.apache.org/site/mail2.html#Commons

On 1/20/06, Xav <xx...@wanadoo.fr> wrote:
>
> Good Morning,
>
> It looks like the fileupload classes parse (or maybe should) the request
> a little bit differently depending if IE or Firefox is used.
> I use the following code:
>
> List /* FileItem */items = upload.parseRequest( request ) ;
> Iterator iter = items.iterator() ;
> *while* ( iter.hasNext() ) {
>   FileItem item = (FileItem) iter.next() ;
>   ...
> }
>
> When the item object is a file the method item.getName() returns just
> the file's name (ex: fooBar.gif) whereas with IE it returns the full
> path of where the file was on the client side (ex: c:\foo\bar\fooBar.gif).


FileUpload is returning to you what the browser sent to the server. IE sends
the full path; most other browsers send only the file name, for security
reasons.

That might be an IE bug but do you think that the fileupload component
> should be changed so that the method getName() always returns the same
> information regardless of the browser used?


FileUpload's job is simply to parse the data sent to the server, not to
interpret it in any way. You might want only the file name, but someone else
might want the full path. That's a decision that can only be made for a
specific application, so it's not something FileUpload should be doing.

--
Martin Cooper


Thanks
> Xavier
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>