Is it ok to upload images to mysql database?

I was making a site where I would need to change the images being displayed very often, so I made a simple forms page where I can upload an image to the database. I heard that I get basically unlimited database storage as long as I don’t make any big requests to it, but would it be fine to save and load images to it?


How exactly would you be storing the images in the database?


As far as I know (based on my limited knowledge of MySQL) there are only 2 methods possible?

  1. Encoding them with base64 and storing as text
  2. Storing them as blobs inside the database

And, of course, you could store image in a folder on the server and then store links inside of a database that reference the files from the server. Are there are any other ways to do it besides these three?

1 Like

Fair usage limits do apply on database usage. If the database server’s storage gets filled up with a huge database because someone thought it was a great way to circumvent the 5 GB disk usage limit, we’re going to take action.

Also, please keep in mind that using PHP to load an image from a database on a different server is computationally quite a bit more costly than just referencing a file on local storage. So depending on how much the images are being queried, you may run in the query usage limits anyway. Remember: it’s not just big queries that can trigger high database usage, having too many queries or querying a poorly optimized table can cause problems too.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.