Reputation: 2019
I am saving user's image at the time of saving user info. At the time of showing the user info I want to show the user image. But it's only showing the url -- [web-app\images\userImages\bappi.jpeg] -- to my form. Can anyone please help me on this ? I am using grails 2.1.0. here is my code below :
my closure in controller >>
def userInfo = {
def user = User.get(1)
def userId = user.id
def username = user.username
def type = user.avatarType.substring(6)
def fileName = username + "." + type
def photo = new File( grailsApplication.config.images.location.toString() + File.separatorChar + fileName)
[userId: userId, username:username, photo:photo]
}
my view page userInfo.gsp >>
<g:form controller="user" action="editUser">
User Name : ${username} <br/>
Photo : ${photo} <p></p>
<g:hiddenField name="userId" id="userId" value="${userId}"/>
<g:submitButton name="editUser" value="Edit" />
</g:form>
Upvotes: 0
Views: 107
Reputation: 1749
use this code:
<g:img uri="${photo}"/>
Or you can try this:
<g:img dir="path/to/image" file="imageFileName.extention"/>
Upvotes: 2