So I have a simple Apache with MySql I am developing a PHP app. I have Users Table in my DB. I vant to let them store Icons.
My question Is what’s the best way of attaching such data as icons (100-250kb’s) to DB – Is it beter to store them Inside DB or store them as File and some how attaching links to icons into DB. What’s the best way? Are there any classes that automate this process (of attaching such data to DB)?
I would store them as files, and reference them from the database. I made the mistake of storing images in the database itself (as BLOB I think) and regretted it the next day when db-connections had to stay opened longer, images didn’t cache when I went to view them multiple times, etc.
I would only suggest storing the image itself in the database if it’s absolutely necessary. If you’re going to be using these images frequently, and showing them in multiple placed, I would suggest storing filepaths only in the database, and keeping the images in the filesystem.
Related: Storing Images in DB – Yea or Nay?