PHP to store images in MySQL or not?

前端 未结 16 2621
离开以前
离开以前 2020-11-28 05:56

I have built a small web application in PHP where users must first log in. Once they have logged in, I intend on showing a small thumbnail as part of their \"profile\".

16条回答
  •  执笔经年
    2020-11-28 06:03

    After researching for days, I made a system storing images and binaries on the database.

    It was just great. I have now 100% control over the files, like access control, image sizing (I don't scale the images dynamically, of course), statistics, backup and maintenance.

    In my speed tests, the sistem is now 10x slower. However, it's still not in production and I will implement system cache and other optimizations.

    Check this real example, still in development, on a SHARED host, using a MVC: http://www.gt8.com.br/salaodocalcado/calcados/meia-pata/

    In this example, if a user is logged, he can see different images. All products images and others binaries are in DB, not cached, not in FS.

    I have made some tests in a dedicated server and results were so far beyond the expectations.

    So, in my personal opinion, although it needs a major effort to achieve it, storing images in DB is worth and the benefits are worth much more the cons.

提交回复
热议问题