title: Multiple Upload Controller in Play Framework / Scala
body: <p>I'm trying to upload multiple files from a "multipart/form-data" form and have them all stored in folders with a batch ID (which is just a timestamp)</p>
  
  <p>The problem is I'm only currently able to save one file.</p>
  
  <p>View</p>
  
  <pre><code>@helper.form(action = routes.Application.upload, 'enctype -&gt; "multipart/form-data", 'multiple -&gt; "") {
  
  &lt;input type="file" name="fsa" multiple=""&gt;
  
  &lt;p&gt;
      &lt;input type="submit"&gt;
  &lt;/p&gt;
  
  }
  </code></pre>
  
  <p>Controller </p>
  
  <pre><code>def upload = Action(parse.multipartFormData) { request =&gt;
              request.body.file("fsa").map { fsa =&gt;
              import java.io.File
                  val filename = fsa.filename 
                  val contentType = fsa.contentType
                  val timestamp: Long = System.currentTimeMillis / 1000
                  fsa.ref.moveTo(new File("/tmp/"+timestamp+"/"+filename))
                  Ok("File uploaded")
              }.getOrElse {
                  Redirect(routes.Application.index).flashing(
                      "error" -&gt; "Missing file"
                  )
              }
      }
  </code></pre>
  
  <p>Is this something to do with reqest.body.file only getting one file, or should i be iterating through an array or something? Not too familiar with scala yet so any help appreciated.</p>