Reputation: 51
Here's what I know:
Here's what I did:
<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:
Upvotes: 1
Views: 405
Reputation: 131137
Change the docBase
attribute. Use D:/uploads
(with slash) instead of D:\uploads
(with backslash).
When dealing with files in Java, you can safely use /
(slash, not backslash) on all platforms.
Regarding the differences you mentioned in the comments when starting the Tomcat from the IDE and from bin/startup.bat
: It's very likely when you start the Tomcat from the IDE, it is not using the same context.xml
your Tomcat is using. Just review the Tomcat settings in the IDE.
How to store uploaded files is a common topic at Stack Overflow. Just look around and you'll get surprised in how this topic is popular.
If you aren't happy enough in storing your files in D:/uploads
or you'll have other servers accessing the files, you could consider storing them in some location in your network. Depending on your requirements, you can have one dedicated server to store your files or just share the folder which contains the files in your current server. The right decision will always depend on your requirements.
Upvotes: 1