what is the simplest way to upload a file in mySql db in play 2.0 ?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- PlayFramework: how to transform each element of a
- Why sometimes there is one of more gap(s) in the v
Another way, you can store reference to photo in database.
In view:
In controller:
Uploading files in the database or in a upload folder and then save a link in the database?
Uploading files is documented: http://www.playframework.org/documentation/2.0/JavaFileUpload
How I did it:
View
In the view, make sure you have the correct
enctype
(this one is based on the twitter bootstrap)The file input:
In your controller
Then iterate trough the attachments and upload them to the upload folder:
Result
The code above result in creating a folder and placing the files in that folder. Example:
Folder: T000345
EDIT : 2012-06-23
If you receive the error about the commons package you have to include this in the file
Build.scala
: