title: Multiple file upload with Spring 3
body: <p>I need to load an unknown number of files at once.
  I found an example, and it works for a known amount of files:</p>
  
  <p>markup:</p>
  
  <pre><code>&lt;form  method="POST" enctype="multipart/form-data"&gt;
  &lt;input name="files[0]" type="file" /&gt;
  &lt;input name="files[1]" type="file" /&gt;
  &lt;input type="submit" value="Send"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String savePhoto(@ModelAttribute("album") Album album,  BindingResult result, SessionStatus status,  MultiPartFileUploadBean file) 
  {
      List&lt;MultipartFile&gt; images = file.getFiles();
      for (MultipartFile photo : images) {
      ...     
      }
      return "redirect:/albums/"+album.getId();
  }
  </code></pre>
  
  <p>MultiPartFileUploadBean:</p>
  
  <pre><code>public class MultiPartFileUploadBean {
      private List&lt;MultipartFile&gt; files;
  
      public void setFiles(List&lt;MultipartFile&gt; files) {
          this.files = files;}
  
      public List&lt;MultipartFile&gt; getFiles() {
          return files;}
  }
  </code></pre>
  
  <p><strong>Yes, it works, but I do not know how the user wants to upload a photo in the album.</strong>
  And I use:</p>
  
  <pre><code>&lt;input name="files[]" type="file" multiple="multiple" /&gt;
  </code></pre>
  
  <p>I'll get a error.</p>
  
  <blockquote>
    <p>Request processing failed; nested exception is
    java.lang.NumberFormatException: For input string: ""</p>
  </blockquote>
  
  <p>I was looking for how to use multiple = "multiple", but found none. I hope for your help.</p>