0

I'm using PHP and MySQL, and don't know where to start with how to set up profile pictures.

It seems all other user data can be held in the mysql table, but I don't think I can put pictures into a mysql table. So how do profile pictures generally work?

James G.
  • 2,852
  • 3
  • 28
  • 52
  • Upload the image to server, store path to image (or just image name if they all are in the same location) in database... – naththedeveloper Aug 02 '13 at 08:02
  • possible duplicate of [Storing Images in DB - Yea or Nay?](http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay) – NDM Aug 02 '13 at 08:05
  • @NickyDeMaeyer Just because I linked to that question in my answer doesn't mean that they're duplicates. They're closely related, but inherently *different* questions. – Danny Beckett Aug 02 '13 at 08:06
  • I just flagged it, let the moderators decide. That's why it says **possible** duplicate. This question could have easily been solved by google... – NDM Aug 02 '13 at 08:08

2 Answers2

2

You can put pictures in a database (using a BLOB field), but I wouldn't, due to the performance hit.

Store the images on the filesystem with PHP, and just store the ID of the picture in the database.

Community
  • 1
  • 1
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
1

I think that what is usually done is set up an upload system for users to upload their images. You just have to link this image with the user by naming it with something like a user ID.

Then you just have to store a link to the uploaded picture in your database, this way you could also imagine allowing user to use remote images although this might not be a good idea.

But as said, the MySQL BLOB field allows storing pictures.

d6bels
  • 1,432
  • 2
  • 18
  • 30