Here's what I know:
- When uploading files given by users, we should put them in a folder outside the deployment folder. Let me call it D:\uploads.
- We should (somehow) add that folder (D:\uploads) as a web app context.
Here's what I did:
- I upload my files to the folder D:\uploads.
- I tried adding the web app context as it's mentionned here by adding the following row to TOMCAT_DIR/conf/server.xml:
<Context docBase="D:\uploads" path="/uploads"/>
But that doesn't have any effect. When consulting http://localhost:8080/uploads/file.png or http://localhost:8080/uploads I get a HTTP Status 404 error.
So what I want to know:
- What did I do wrong ? How can I add my upload folder to Tomcat?
- Is there any better approach when it comes to uploading files ? Because I'm wondering what should I change if I want to deploy my application to another server where there's no D:\uploads.