-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
i need to call a fileselectbox in pure java which returns the filename and the full pathname of the file.
I played with :
media = Fileupload.get();
System.out.println(media.getName());
I'm missing the getter for the full pathname. Can anyone help me on this?
thanks Stephan
Edit:
media = Fileupload.get();
System.out.println(media.getName());
File file = new File(media.getName());
System.out.println(file.getAbsolutePath());
Tested with Tomcat started from Eclipse it gives me the path where my eclipse start.bat is in?????
I select the file in Chrome (FileUpload) from d:\ccc\queries.pdf and get as result:
Media media;
media = Fileupload.get();
File file = new File(media.getName());
System.out.println("file.getName(): " + file.getName());
System.out.println("file.getPath(): " + file.getPath());
System.out.println("file.getCanonicalPath(): " + file.getCanonicalPath());
System.out.println("file.getAbsolutePath(): " + file.getAbsolutePath());
log:
file.getName(): queries.pdf
file.getPath(): queries.pdf
file.getCanonicalPath(): D:\Entwicklung\queries.pdf
file.getAbsolutePath(): D:\Entwicklung\queries.pdf
any idea are welcome.
By deploying the war-file on an external Tomcat Instance. I get as log result for the Path the Tomcat Directory:
D:\Tomcat_7........\bin\queries.pdf
Did you mean you want to get the client's file path like "d:\ccc\" ? I think it is not possible due to security issue.
See Stackoverflow for security reason you can not do it.
Asked: 2013-03-07 11:10:09 +0800
Seen: 21 times
Last updated: Mar 11 '13