title: multiple file upload in grail
body: <p>I am trying to copy multiple files using the request or HttpServletRequest features.</p>
  
  <p>I have been able to loop through all the selected files in a controller action where I have accessed the MultipartFile object for each file - here is the action code:</p>
  
  <pre><code>request.getFileNames().each{
      request.getFiles(it).each 
      { file -&gt;
          // loop through all files selected
      println "name: $file.name Originalfilename: $file.originalFilename contentType: $file.contentType"
          file.transferTo( new File( userDir, file))                  
      } // eo for loop
  } // eo requect.getFiles().each....
  </code></pre>
  
  <p>I get a groovy runtime error at the transferTo line - the error message being:</p>
  
  <blockquote>
    <p>Could not find matching constructor for: java.io.File(java.io.File, org.springframework.web.multipart.commons.CommonsMultipartFile)</p>
  </blockquote>
  
  <p>If I comment out the transferTo line the printout line line the loop produces the correct MultipartFile information about each selected files.</p>
  
  <p>See output for two files selected here:</p>
  
  <blockquote>
    <p>name: file[] Originalfilename: for-sale.gif contentType: image/gif</p>
    
    <p>name: file[] Originalfilename: front.gif contentType: image/gif</p>
  </blockquote>
  
  <p>How can I invoke transferTo to do the copy?</p>
  
  <p>-mike</p>