How to include a picture type in a form in Play!2 in Scala?
===

According to [this guide][1], one can upload files by writing the html form by hand. I want to handle file upload as part of a bigger form that includes text fields (for example name and email). Here is what I have to far (quite ugly):

    def newUser = Action(parse.multipartFormData) { implicit request =>{   
        //handle file
        import play.api.mvc.MultipartFormData.FilePart
        import play.api.libs.Files.TemporaryFile

        var uploadSuccessful = true 
        var localPicture: FilePart[TemporaryFile] = null
        
        request.body.file("picture").map { picture =>
        localPicture = picture   }.getOrElse {
        uploadSuccessful = false   }
        
        //process the rest of the form
        signupForm.bindFromRequest.fold(
          errors => BadRequest(views.html.signup(errors)),
          label => {
            //file uploading code here(see guide), including error checking for the file.

            if(uploadSuccesful){
            User.create(label._1, label._2, label._3._1, 0, "NO PHOTO", label._4)
            Redirect(routes.Application.homepage).withSession("email" -> label._2)
            } else {
            Redirect(routes.Application.index).flashing(
            "error" -> "Missing file"
            }
          })
         }   }


This looks tremendously ugly to me. Note that I have defined a signupForm somewhere that includes all fields (apart from the file upload one). My question is: Is there a prettier way of going about this? Perhaps by including the file field in the signupForm and then handling errors uniformly.

  [1]: http://www.playframework.org/documentation/2.0.2/ScalaFileUpload