Should I use mysql to store the user profile picture ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Should I use mysql to store the user profile picture ?

Post by aneuryzma »

Should I use mysql to store the user profile picture together with other informations ?
Could you suggest me a tutorial to upload the images into the database ?

thanks
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Should I use mysql to store the user profile picture ?

Post by papa »

I'd upload the picture on the server and store the path in the database.
User avatar
danielwalters6
Forum Commoner
Posts: 31
Joined: Fri May 11, 2007 1:17 pm
Location: Cambridge, England, UK

Re: Should I use mysql to store the user profile picture ?

Post by danielwalters6 »

Keep database size to a minimum - just store the file path!
This way, you can setup to have several images per entry.
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Re: Should I use mysql to store the user profile picture ?

Post by aneuryzma »

ok! thanks!

should I pay attention to any security risk ?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Should I use mysql to store the user profile picture ?

Post by papa »

If you want users to upload their own picture you need to do some limitations in size and file type for example.
aneuryzma
Forum Contributor
Posts: 106
Joined: Sat May 17, 2008 7:03 am

Re: Should I use mysql to store the user profile picture ?

Post by aneuryzma »

ok, I'm already limiting the size.

How can I limit the type ? Just checking for extension ?
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Re: Should I use mysql to store the user profile picture ?

Post by mickd »

Maybe with a function like exif_imagetype. Though i haven't used it myself.

I would assume you wouldn't want to just check the file extension because it could even be an executable, but with its extension changed.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Should I use mysql to store the user profile picture ?

Post by pickle »

getimagesize() can give you the file type.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply