Recently did the project, used to upload download files, see java--file upload and download.
Requirements: Uploaded files can be placed on any server (that is, different IP), and then can be accessed in different places.
Note: If you place the uploaded file directly under Tomcat's WebApp file on your server, you can access it anywhere when you turn on Tomcat.
Below is the picture storage location, which is stored under Tomcat's WebApps
The access path is as follows
Http://192.168.2.67:8080/asf-logo.png
The front is my host IP and port, followed by the file name of the picture
Now the need to change: The uploaded image is not stored under WebApps, but exists in the computer's D disk, but also need to remotely access to the picture.
The implementation steps are as follows:
1. Modify the Tomcat Server.xml file. Figure below
2. Image upload Location
The access path is as follows
Http://192.168.2.67:8080/Resource/caren/User/1000000001/bg.png
Tomcat--Get the upload file path