I am developing a website using Yii framework. On my website I have user profiles (already implemented). I will have a file uploader so that users can upload profile images. Some profiles may be available to the public, others will be private. Private profiles should be inaccessible to public users, and the images on this profile may not be accessible to anyone except for the owner of the profile.
I have read that it is a bad idea to store images in a MySQL database as it kills performance and may be disallowed on my webhosts. I have thought of storing the images in my protected directory, but if done here, I will not be able to link to the images at all. How then will I be able to display images on valid profiles (public profiles, or profiles belonging to the user?)
Any hint or idea will be greatly appreciated (related to Yii, php or any other). Let me know if my question is unclear. Thank you.
*BTW, I have never had a formal web development course, and like many others I have learnt everything I know in my own time, so it's very possible that I am missing a very simple/obvious solution.