【问题标题】:Playframework file upload errorPlayframework文件上传错误
【发布时间】:2012-09-21 22:12:39
【问题描述】:

我正在使用Handling file upload 示例。上传文件时,服务器显示错误:Missing boundary header

这是我正在做的事情:

def upload = Action(parse.multipartFormData) {implicit request =>
    request.body.file("picture").map { picture =>
      import java.io.File
      val filename = picture.filename
      val contentType = picture.contentType
      picture.ref.moveTo(new File("/users/pictures"))
      Ok("File uploaded")
    }.getOrElse {
      Redirect(routes.Application.index).flashing(
        "error" -> "Missing file"
      )
    }
  }

在我的表格中我已经这样做了:

@helper.form(action = routes.Application.upload, 'enctype -> "multipart/form-data") {

<input type="file" name="picture">

<p>
    <input type="submit">
</p>

}

我在这里做错了什么?

【问题讨论】:

    标签: scala file-upload playframework-2.0


    【解决方案1】:

    我创建了一个新游戏!项目并使用了您的代码,它似乎工作正常(在 OSX 上使用了最新的 Chrome)。如果您没有 'enctype 参数,我会理解该错误。

    Here's the entire project。看看这是否有效。

    【讨论】:

    • 感谢您的回答。你的项目运行良好。我真的不知道我的有什么问题。如果有用的话,我会尝试修复它并在这里发表评论。
    • 当我在我的routes 文件中使用POST 方法时,该错误已修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-28
    相关资源
    最近更新 更多