开发者

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)

Everything works fine, but when i clean and build my project. The whole folder of PhotoGallery gets deleted. 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 folder开发者_如何学JAVAs?


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.

Instead, create a directory somewhere else to hold the images; e.g. /var/yourProject/PhotoGallery/ Alternatively save the images in some kind of database / filestore.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜