wood burning stoves*
The moose likes Struts and the fly likes Struts2 File Upload - Client's filepath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 File Upload - Client Watch "Struts2 File Upload - Client New topic
Author

Struts2 File Upload - Client's filepath

Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
Can someone help me please...
We are using Struts2 file upload tag in my jsp for our users to upload a file.
In my action class, I could get the fileName that the user uploaded but is there a way I can get the entire filePath on client's machine?
If it is not possible, is there any other work around for me to do this.

Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hi Mathew. Getting the full file path on the clients machine is not possible. Browsers do not allow you to expose this kind of information to the webpages since it will be a huge security risk. By exposing the clients directory structure, a potential hacker may be able to retrieve any file from the filing system .


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
Saif, thank you so much !!
Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
Saif, Thanks for your clarification.
We have a similar application (not in struts) that captured the entire client path.
So is the reason I was trying to check if we could do the same with struts2.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

We have a similar application (not in struts) that captured the entire client path.

Can I ask how were you achieving that ? By an ActiveX object ?
Mathew Geraldo
Greenhorn

Joined: Mar 27, 2013
Posts: 19
Saif,
All I know is that the application was written in PERL CGI .
So maybe there is something in PERL/CGI that would allow access to clients file path.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18168
    
    8

It used to be the case that Internet Explorer would upload the whole path, instead of just the file name. Other browsers don't do that, because of the security risks referred to in an earlier post. Perhaps recent versions of IE have fixed this problem -- I don't know because I haven't checked.

Perhaps your clients were all IE users?
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Saif,
All I know is that the application was written in PERL CGI .
So maybe there is something in PERL/CGI that would allow access to clients file path.

I see, I'll take a look at it just for knowledge purposes.

It used to be the case that Internet Explorer would upload the whole path, instead of just the file name. Other browsers don't do that, because of the security risks referred to in an earlier post. Perhaps recent versions of IE have fixed this problem -- I don't know because I haven't checked.

Perhaps your clients were all IE users?

Yes Paul , I can say about the older versions of IE ( prior to 7 ) , they used to send the complete physical address of the clients file system instead of just the file name although I am also not sure about the newer versions of IE. Maybe Mathew's was a very particular scenario where all clients were supposedly using an old IE version.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 File Upload - Client's filepath
 
Similar Threads
struts2
struts2 upload
upload image usinng struts2
Struts2 file upload to a specific path
Struts2