Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

file upload changing the src path  RSS feed

 
prajapatisagar Sagar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
while uploading file i am using

srcPath=config.getServletContext().getRealPath("/")+"uploadedFiles/"+Name;

File savedFile = new File(srcPath);

the srcPath is d:/usr/tomcat/webapps/gblhrm/uploadedFiles/Names

now i want srcPath to be d:/usr/tomcat/webapps/uploadedFiles how can i do this
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't.

You should NEVER upload files to locations inside of a WAR. Aside from the fact that it will produce major headaches, it's technically a violation of the J2EE spec despite being physically possible in some (but not all) webapp servers (depending on how they're configured).

Designate a dedicated upload directory that's outside of both the webapp AND the Tomcat server directory trees and use that. I normally make that directory path be a configurable option, but that's just for flexibility. The important thing is that the upload directory should not be inside the deployed WAR.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!