简体   繁体   中英

Tomcat deleting my all uploaded images when ever i re-run application through eclipse

I am creating web application in Java (Spring framework); using Eclipse IDE and Tomcat web server.

I have implemented a functionality to upload user images. Images are uploaded to my application context.

But whenever I re-run the application from Eclipse, Tomcat deletes my all existing images.

Tomcat or any web container creates an instance of your project when you run. All the target files and resources are copied to this instance, which is different from actual project location and is the context of the application.

So, when you upload files to the application context they are contained in it only till your server is running.

But if you store images/files in some other location you wont be able to access them till you restart the server.

You can store files in app context and other location (eg. resources) to overcome this problem.

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM