I am creating a website with jsp&servlet
and I want to ask :
What’s the best way to store an image in a database (mysql) and retrieve it
to using it as profile’s picture
And how can i do that?
Thanks you all in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two common solutions :
directly in the database in a byte field
on the disk, with the path stored in database (I personnaly like to use as name the SHA1 of the file, so I cannot have two times the same file, with the path being a/b/cdef if the SHA1 is abcdef)
Both solutions work very well. The first solution has for advantage to have only one file to backup, to enable rollback, and so on. The second may be more natural as a disk file system is made to store files.