I'm trying to upload an image to the DB but when I try to see what is in the params
, I find in fileupload
is the image's name something like org.springframework.web.multipart.commons.CommonsMultipartFile@eeed792
. For example params [fileupload:android-logo.jpg]
.
Here is the domain class:
class Photos {
Date dateCreated
byte [] photo
Date lastUpdated
static constraints = {
}
static mapping ={ photo(sqlType:"BLOB") }
}
the GSP :
<label>Photos:</label>
<input class="inputFiles" type="file" name="fileupload" multiple="multiple" accept="image/*" />
What may be causing this ?
File uploads don't get directly injected into params. You have to use request.getFile('paramname')
Take a look at this: http://www.slideshare.net/cavneb/upload-files-with-grails