html - How to load an image using its real path in Grails -
my idea save images user uploads outside context path follow:
d:\somefolder\myweb\web-app\ d:\somefolder\imagesoutsidecontextpath\
the code next (working locally):
string path = servletcontext.getrealpath("/"); string parentfolder = new file(path).getparentfile().getparent(); string imagesfolder = parentfolder + "\\imagesoutsidecontextpath";
another idea (if 1 doesn't work on server) save images in current user's home folder @hoànglong suggested me.
but i'm not able load images view. think this article official documentation not valid purpose. the next code desn't load anything:
<img src="d:\\somefolder\\imagesoutsidecontextpath\\bestimageever.jpg" alt="if don't see message, i'll happier">
how use real path instead url path load these images?
you can set src
action
. user not know images stored (security) , can change logic display them.
in action, image , print bytes. example here.
Comments
Post a Comment