I want to persist an Image in my Article Entity.
Is this possible with Doctrine2?
How do i do this?
Best Regards,
bodo
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.
This is pretty simple using the ODM setup with the @File type.
For a ORM entity, I would look at creating a column like so.
NOTE: Use this link to add the blob type to Doctrine2
How add BLOB type in Doctrine 2 using Symfony 2
Then set that property with the raw data of the image. You will want to store things like the length, content-type, width and height along with the raw data so that you can create the right headers to retrieve the image and display it in the browser or download it.
That should be enough to get you started on the right path, or decide not to bother.