skip to Main Content

I’ve built a simple website with authorization and registration system.
So I have user accounts and I wonder where to store profile pictures for every user.
I tried to store them in MYSQL in BLOB, but I don’t think it is the best way to do this.

2

Answers


  1. The short answer is in most cases a file system (eg. the server where your code is hosted, if that’s an option).

    Read this short article:

    Storing images in a database table is not recommended. There are too many disadvantages to this approach. Storing the image data in the table requires the database server to process and traffic huge amounts of data that could be better spent on processing it is best suited to. A file server can process such image files much better. Source: Store Images in the Database

    If you do not have access to storing images on your server or enough space, you could take a look into hosting you images on an image server.

    Login or Signup to reply.
  2. Most people have the opinion that files should reside on the filesystem, outside the database. But there are exceptions to every rule. There are some good reasons to keep large binaries inside the database, depending on your project requirements.

    See some of my past answers on this topic:

    I also cover this in the chapter "Phantom Files" in my book, SQL Antipatterns Volume 1: Avoiding the Pitfalls of Database Programming.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search