|
I'm following documentation from here https://www.playframework.com/documentation/2.5.x/ScalaFileUpload to handle file upload in form. My code is here:
Whenever I submit this form, even if I didn't select file in the form I'm getting something like this in console:
I can't understand why is this so. I think there are should be None in Actually I was tried to downgrade Play to 2.5.4 and got the same result. |
def upload = Action(parse.multipartFormData) { request =>
request.body.file("picture").map { picture =>
import java.io.File
val filename = picture.filename
val contentType = picture.contentType
picture.ref.moveTo(new File(s"/tmp/picture/$filename"))
Ok("File uploaded")
}.getOrElse {
Redirect(routes.HomeController.uploadtest()).flashing(
"error" -> "Missing file")
}
}
@()
@helper.form(action = routes.HomeController.upload, 'enctype -> "multipart/form-data") {
<input type="file" name="picture">
<p>
<input type="submit">
</p>
}