You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ambaris Mohanty <am...@lifestylestores.com> on 2007/06/15 07:40:13 UTC

get real path of a file from action class

Hi all,

Can anybody tell me how to get the real path of a file from an action class?
I'm using struts 1.2.9.

Thank you,

AM


RE: get real path of a file from action class

Posted by Ambaris Mohanty <am...@lifestylestores.com>.
Thank you Deepak,
It works fine.

-----Original Message-----
From: Deepak Kumar [mailto:deepak123@roseindia.net] 
Sent: Friday, June 15, 2007 11:22 AM
To: Struts Users Mailing List
Subject: RE: get real path of a file from action class

Hi,

You can get it by using the code:

 //Get the servers upload directory real path name
    String filePath = getServlet().getServletContext().getRealPath("/")
+"upload";

Have a look at
http://www.roseindia.net/struts/strutsfileuploadandsave.shtml.

Here you will find the code to save the file on the server also

Thanks
Deepak Kumar

-----Original Message-----
From: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com]
Sent: Friday, June 15, 2007 11:10 AM
To: 'Struts Users Mailing List'
Subject: get real path of a file from action class


Hi all,

Can anybody tell me how to get the real path of a file from an action class?
I'm using struts 1.2.9.

Thank you,

AM



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: get real path of a file from action class

Posted by Deepak Kumar <de...@roseindia.net>.
Hi,

You can get it by using the code:

 //Get the servers upload directory real path name
    String filePath = getServlet().getServletContext().getRealPath("/")
+"upload";

Have a look at
http://www.roseindia.net/struts/strutsfileuploadandsave.shtml.

Here you will find the code to save the file on the server also

Thanks
Deepak Kumar

-----Original Message-----
From: Ambaris Mohanty [mailto:ambaris.mohanty@lifestylestores.com]
Sent: Friday, June 15, 2007 11:10 AM
To: 'Struts Users Mailing List'
Subject: get real path of a file from action class


Hi all,

Can anybody tell me how to get the real path of a file from an action class?
I'm using struts 1.2.9.

Thank you,

AM



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org