Reputation: 2280
I'm following along with Plays! documentation on uploading files. For some reason when using "/tmp/picture.jpg"
, my file does not get uploaded to my tmp folder but if I link to it like such /Users/Me/Sites/play-app/tmp/picture.jpg
, then it gets uploaded.
So how can I upload files to the tmp folder without giving the that long path? (because I will deploy it soon and the path with not match)
Upvotes: 0
Views: 1010
Reputation: 18446
It seems like you are looking for a way to get the absolute path of your Play application. Try this (if you are using Scala):
import play.api.Play
val playroot = Play.application().path().getPath()
val filename = playroot + "/tmp/picture.jpg"
Or, if you are using Java:
import play.*;
String playroot = Play.application().path().getPath();
String filename = playroot + "/tmp/picture.jpg";
Upvotes: 1