File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes browse button returning just filename in Firefox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "browse button returning just filename in Firefox" Watch "browse button returning just filename in Firefox" New topic
Author

browse button returning just filename in Firefox

vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
Hi all,

once after selecting the filename and submit the form the firefox is sending only the filename without the full path.
for eg: if i select a file c:\text.htm the firefox is returning just text.htm as parameter.
Is there a way to pass the full path as parameter.
In IE it is working fine.
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
Does anybody know the answer?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please read this.
[ June 01, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I do not think firefox returns the fill path as a security measure.

what are you doing on the server to try to get the full path?

Eric
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
user should select a xml file from browse button and the server will parse the xml file and update the database accordingly. since firefox is returning just filename the servlet is not able to get the xml file
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Originally posted by vijaya bacina:
since firefox is returning just filename the servlet is not able to get the xml file


You should not need the file path in any case. How are you reading the file, with file I/O or with a file upload?

If the former, your system will ONLY work when the client and the server are on the same machine. Is this what you really intened?
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155


where path=document.form.browse.value; which is equal to text.xml
file.exists() is returning false so not able to read the file.
the server and client will be on different machines. Is this not possible with firefox atall?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18989
    
    8

Firefox has nothing to do with it. If that code you posted runs on your server, then the File object refers to a file on your server, not to a file on the client. That just isn't how you upload a file, so there is no point in trying to make it work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

See the JSP FAQ on how to really perform a file upload.
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
Thank you very much.
I used apache commons for file upload and it is working fine now.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Olly Morgan
Greenhorn

Joined: Jun 11, 2007
Posts: 1
Hi guys, I have a similar problem, which is not solved by the JSP FAQ...

In our case we are not trying to upload the file, just allow users on our intranet to specify where their file is, and using the Browse button avoids mistypes... it's part of an application where users specify future deployments, and this is part of the documentation they are providing. So we are not (at this stage) interested in the file, only where it is. So, as much as I understand that the primary function of the Browse button is for uploads, Firefox's behaviour is kind of unhelpful.

Any one have any suggestions as to whether Firefox can configured so that the browse button does not have this security feature? Or any Javascript examples that allow a user to select a file.

Thanks for any help

Olly
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

No, I'm afraid that you will have to search for another solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: browse button returning just filename in Firefox