PHP to store images in MySQL or not?

前端 未结 16 2659
离开以前
离开以前 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:13

    As the others suggested:

    • Store the images in the filesystem
    • Do not bother to store the filename, just use the user id (or anything else that "you already know")
    • Put static data on a different server (even if you just use "static.yourdomain.com" as an alias to your normal server)

    Why ?

    The bigger your database gets the slower it will get. Storing your image in the database will increase your database size. Storing the filename will increase your database size.

    Putting static data on a different server (alias):

    • Makes scaling up a lot easier
    • Most browsers will not send more than two requests to the same server, by putting static data on a "second" server you speed up the loading

提交回复
热议问题