我似乎无法将文件上传到我的本地目录,将它们放置在appdata / Temp目录中有效,但是它只是临时的,这就是为什么我想将它们上传到Temp以外的其他目录
我尝试了一些教程,但似乎收到了相同的错误:
[NoSuchFileException: C:\*****\multipartBody2177348957005612751asTemporaryFile -> \*****\Knipsel.PNG]
views.html.index:
@helper.form(action = routes.Application.uploadFile, 'enctype -> "multipart/form-data") {
< input type="file" name="fileUpload">
<p>
<input type="submit" value="Upload">
</p>
}
Application.scala
import java.io.File
def uploadFile = Action(parse.multipartFormData) { request =>
request.body.file("fileUpload").map { picture =>
val Filename = picture.filename
val contentType = picture.contentType.get
picture.ref.moveTo(new File("/*****/" + picture.filename))
}.getOrElse {
Redirect(routes.Application.index)
}
Ok("File has been uploaded")
}
路线:
POST /upload controllers.Application.uploadFile
教程:
http://blog.knoldus.com/2013/01/22/play-framework-uploading-a-file-to-server/
https://www.playframework.com/documentation/2.4.x/ScalaFileUpload
我希望这是足够的信息对我有帮助,在此先感谢
PS我正在使用IntelliJ 15.0,如果有什么区别
看来您是从Windows计算机上运行本教程的,所以我要更改这一行:
picture.ref.moveTo(new File("/*****/" + picture.filename))
对此:
picture.ref.moveTo(new File("""C:\*****\""" + picture.filename))