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

后端 未结 7 1431
生来不讨喜
生来不讨喜 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:42

    I suggest having a table where you store user data like username, first name. In that table create a field called something like "avatar" in which you can store a file reference.

    Assuming your user avatars are stored in: htdocs/images/avatars/ And user apikot has the avatar "avatar.jpg" stored agains it's user in the database, you could then compile the following url when generating an image tag: "/htdocs/images/avatars/avatar.jpg".

    0 讨论(0)
提交回复
热议问题