文件上传代码
request.body.file("image").map { ing =>
val target = new java.io.File(s"./uploads/${ing.filename}")
ing.ref.moveTo(target, true)
}
如何将ing.filename连接到AboutImages“image”对象,以便我可以更新数据库!
这是诺贝尔奖:object AboutImages {
val images = {
get[Long]("about_us_images.id") ~
get[String]("about_us_images.image") ~
get[Option[Date]]("about_us_images.created_at") ~
get[Option[Date]]("about_us_images.updated_at") ~
get[Option[Int]]("about_us_images.position") ~
get[String]("about_us_images.name") map {
case id~image~created_at~updated_at~position~name => AboutImages (id, image, created_at, updated_at, position, name)
}
}
形式是:
val details: Form[AboutImages] = Form(
mapping(
"id" -> longNumber,
"image" -> text,
"created_at" -> optional(date),
"updated_at" -> optional(date),
"position" -> optional(number),
"name" -> nonEmptyText
)(AboutImages.apply)
(AboutImages.unapply)
)
答案 0 :(得分:0)
我不完全确定我理解您的问题 - 您是否在访问除文件上传之外的表单组件时遇到问题?