How to store uploaded images on the server filesystem to make them available for direct link?
Using Java and Tomcat.
How can I make uploaded images that are stored somewhere on a defined location on the server to be available to a direct link from the browser?
For example: On the server: C:\images_folder\example.jpg Linked from webpage: http://www.example.开发者_如何学JAVAcom/MyWebApp/example.jpg
Is it possible to do or it requires quite a bit of work?
I guess the easy way would be to just store them under the WebContent directory and put them in a directory like uploaded_images under all the jsps files but that seems off.
Any suggestions?
Thanks!
Default Tomcat setup includes servlet to serve static content. I believe, you will need to place in webapps/ROOT. Look where documentation goes, that is served when you first start it.
Place your images there and you are done.
精彩评论