How do I save the file name in the database

creativename

When I add a new record in a database using a form, I also can upload an image. These two are not linked together; record goes in database and the image goes in an folder on my desktop, so to know which image belongs to which record, I want to put the filename in a column. How do i approach this?

Im using PlayFramework 2.4, Scala, H2 Database and Anorm for my Project

salc2

In your html form you need to have an input tag of file type, something like:

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

And in your scala method Controller, where you are getting the form submit, something like:

def save = Action(parse.multipartFormData) { request =>
  request.body.file("picture").map { picture =>
    import java.io.File
    val filename = picture.filename
    println(filename)
   Ok("saved")
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Codeigniter after renaming file for upload how do i save the new file name to my database

From Dev

how do i save three inputs to a file with same name as the user?

From Dev

How do Insert / Save new file name after rename to my database?

From Dev

How do I save code snippets to a database?

From Dev

How do I save input to a database

From Dev

How do I save PHP session data to a database instead of in the file system?

From Dev

How do i save raw php code to database or text file for sending email message?

From Dev

How do I save database configuration without writting them on my python file

From Dev

arangoimp, how do I specify database name?

From Dev

How do I serialize or save to a file a Thunk?

From Dev

How do I save terminal output to a file?

From Dev

How do I save a file to a subdirectory in InternalStorage

From Dev

How do I save the output of a script to a file?

From Dev

How do I save a Form as an image to a file?

From Dev

How do i save a file in fastcoloredtextbox?

From Dev

How do I save terminal output to a file?

From Dev

Do I put constants in database or use file to save it

From Dev

How do I save a Save/Load a text file in Red

From Dev

How do I name the .bowerrc file?

From Dev

How do I ask the user for a file name?

From Dev

How do I replace substring in a file name?

From Dev

How do I save a string from database query using codeigniter

From Dev

How do I save data from a checkbox array into database

From Dev

How do I save to Django's database manually?

From Dev

How do I Save phone Contacts to my own database

From Dev

How do I use a pre save hook database value in Mongoose?

From Dev

How do I save the scraped data from Nokogiri to a Rails database?

From Dev

How do I save the name of a object in another variable?

From Dev

How do I save the variable name in awk sums?

Related Related

  1. 1

    Codeigniter after renaming file for upload how do i save the new file name to my database

  2. 2

    how do i save three inputs to a file with same name as the user?

  3. 3

    How do Insert / Save new file name after rename to my database?

  4. 4

    How do I save code snippets to a database?

  5. 5

    How do I save input to a database

  6. 6

    How do I save PHP session data to a database instead of in the file system?

  7. 7

    How do i save raw php code to database or text file for sending email message?

  8. 8

    How do I save database configuration without writting them on my python file

  9. 9

    arangoimp, how do I specify database name?

  10. 10

    How do I serialize or save to a file a Thunk?

  11. 11

    How do I save terminal output to a file?

  12. 12

    How do I save a file to a subdirectory in InternalStorage

  13. 13

    How do I save the output of a script to a file?

  14. 14

    How do I save a Form as an image to a file?

  15. 15

    How do i save a file in fastcoloredtextbox?

  16. 16

    How do I save terminal output to a file?

  17. 17

    Do I put constants in database or use file to save it

  18. 18

    How do I save a Save/Load a text file in Red

  19. 19

    How do I name the .bowerrc file?

  20. 20

    How do I ask the user for a file name?

  21. 21

    How do I replace substring in a file name?

  22. 22

    How do I save a string from database query using codeigniter

  23. 23

    How do I save data from a checkbox array into database

  24. 24

    How do I save to Django's database manually?

  25. 25

    How do I Save phone Contacts to my own database

  26. 26

    How do I use a pre save hook database value in Mongoose?

  27. 27

    How do I save the scraped data from Nokogiri to a Rails database?

  28. 28

    How do I save the name of a object in another variable?

  29. 29

    How do I save the variable name in awk sums?

HotTag

Archive