Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to upload multiple files in grails

I have a form that contains multi file upload like this one

<g:form name="legalActionForm" controller="legalAction" action="save" enctype="multipart/form-data">
<input type='file' name='documentFile'/> <input type='text' name='documentDate'/>
<input type='file' name='documentFile'/> <input type='text' name='documentDate'/>
<input type='file' name='documentFile'/> <input type='text' name='documentDate'/>
<input type='file' name='documentFile'/> <input type='text' name='documentDate'/>
<input type='file' name='documentFile'/> <input type='text' name='documentDate'/>
<input type='submit' value='update'/>
</g:form>

user can add more if needed ... how to get each file using iterators ?

if only one file I use request.getFile('documentFile'); but if I tried with request.getFileNames().each{obj -> println("${obj}"); } I only got the first one ..

like image 698
nightingale2k1 Avatar asked Dec 10 '10 07:12

nightingale2k1


1 Answers

request.getMultiFileMap().documentFile.each {
    println it.originalFilename
}
like image 198
Cassio Landim Avatar answered Oct 03 '22 02:10

Cassio Landim