What is the best way to store users images using PHP and MySQL?

后端 未结 7 1435
生来不讨喜
生来不讨喜 2021-02-03 10:58

I was wondering what is the best way to store a users upload images like an avatar and so on using PHP and MySQL? Where should I begin? And is there a good article on this?

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 11:32

    If I were you, I would just save the image somewhere in your sites directory and then save the link to the image in MySQL, if you really want to save it in a database, I would read it into a string and then base64_encode() it and then save it in the database.

    There are all sorts of little troubles you will face by storing them in a database, you will have to create scripts to echo them back out ect, and the server and database load will be greatly increased. If I were you, I'd just store the reference.

提交回复
热议问题