getting complete full path of a file name
Greetings Java developer!
I am having a problem in my JSF program to get a complete full path of a file name if I runs it using a browser other than IE.
Here is the code I used to retrieve the complete full path of a fine name in my program.
UploadedFile uploadedFile =
fileUpload1.getUploadedFile();
String uploadedFileName =
uploadedFile.getOriginalName();
note: fileUpload1 is a UI component of sun.rave.web.ui.model.
The expected result would be i.e.:
C:\\abc\file.txtor/abc/file.txt
It works in the IE browser, but does NOT in Mozilla, Firefox, and Netscape. Is anyone have a clue to resolve this problem? Please advice.
Thanks!
jsfNewbie
Message was edited by:
jsfNewbie
[773 byte] By [
jsfNewbiea] at [2007-11-27 11:36:26]

# 1
Hi,
The tutorial on file upload
http://developers.sun.com/jscreator/learning/tutorials/2/file_upload.html
has been updated to include this information. Pasting the relevant code from the tutorial:
public String uploadFileButton_action() {
UploadedFile uploadedFile = fileUpload1.getUploadedFile();
String uploadedFileName = uploadedFile.getOriginalName();
// Some browsers return complete path name, some don't
// Make sure we only have the file name
// First, try forward slash
int index = uploadedFileName.lastIndexOf('/');
String justFileName;
if ( index >= 0) {
justFileName = uploadedFileName.substring( index + 1 );
} else {
// Try backslash
index = uploadedFileName.lastIndexOf('\\');
if (index >= 0) {
justFileName = uploadedFileName.substring( index + 1 );
} else {
// No forward or back slashes
justFileName = uploadedFileName;
}
# 2
Hi Rradhika,
Thank you for your respond to my question. Yes, I am aware about the upload tutorial and its example. If you see on my description that I am expecting the value of "uploadedFileName" variable below is i.e.:
"C:\\abc\file.txt"but NOT"file.txt"
Only IE can display the value of "uploadedFileName" like "C:\\abc\file.txt". Other browsers like Mozilla, Firefox, and Netscape are displaying"file.txt".This is NOT what I wanted.
So, do you have another solution?
Thanks!
jsfNewbie
UploadedFile uploadedFile = fileUpload1.getUploadedFile();
String uploadedFileName = uploadedFile.getOriginalName();