[英]Where should i save my images that user uploads? java web application
I am saving the image at this location :- 我将图像保存在此位置:-
private static String photoGalleryPath = "/Common/PhotoGallery/";
I save the image at context.getRealPath(photoGalleryPath)
我将图像保存在
context.getRealPath(photoGalleryPath)
Everything works fine, but when i clean and build my project. 一切正常,但是当我清理并构建项目时。 The whole folder of PhotoGallery gets deleted.
PhotoGallery的整个文件夹将被删除。 This looks very funny to me :).
这对我来说看起来很有趣:)。 Why does it delete my whole folder everytime?
为什么每次都删除我的整个文件夹? And what more should i do to tell the extra smart Glassfish to not to delete my folders?
而且我该怎么做才能告诉额外的智能Glassfish不要删除我的文件夹?
You probably should not be storing data within your servlet's webContent directory because (as you observe) redeployment of the WAR may blow it away. 您可能不应该将数据存储在servlet的webContent目录中,因为(如您所观察到的)重新部署WAR可能会使其失效。
Instead, create a directory somewhere else to hold the images; 而是在其他位置创建一个目录来保存图像。 eg
/var/yourProject/PhotoGallery/
Alternatively save the images in some kind of database / filestore. 例如
/var/yourProject/PhotoGallery/
或者将图像保存在某种数据库/文件存储中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.