This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It may be possible with the PUT method, but most of the time PUT and DELETE are not allowed. What you could do is write a little page with an <input type="file"> element that allows users to POST a file. Your server code (JSP, servlet, PHP) must then take the uploaded file and move it to your img folder.
I forget to mention that i have the inputstream which i want to write to the file. But my doubt is that how to get the
path for writing the file. The application will have its own path depending on where it is deployed.
Can we use something like getcontextpath or getRealpath or any other method is there to find the path?
ServletContext.getRealPath is exactly the way to go.
Joined: Mar 09, 2010
Rob Prime wrote:ServletContext.getRealPath is exactly the way to go.
Whether the ServletContext.getRealPath() will work if i am using apache tomcat as web server. I read that it wont work if i deploy the application in
war format. is that correct? and if so, is there any workaround for that ?