开发者

How to store uploaded images on the server filesystem to make them available for direct link?

开发者 https://www.devze.com 2023-03-08 12:52 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消