I was wondering if you can make a tutorial on how to add a user profile picture/avatar...or a gallery for users from which they can pick the profile avatar/picture...that will be interesting...
thank you and regards.
User Profile Avatar
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: User Profile Avatar
Its fairly simple.
You probably know how to upload an image (im sure jacek has covered this) And im sure you know how to insert data into a database, and how to fetch data and how to echo out data.
You have everything you need there.
When you upload the image, make sure you upload it to a certain location where they are all stored, and make sure the file name is unique (good technique for this is often just the timestamp, however for popular websites, adding a salt and md5ing it will make it completely unique.
This data you then store into the database alongside the user profile data (in the same row as the person it corresponds to. For the image you store the location on the server from root. Eg. /profile/images/image0123133131.jpg
When you fetch that data on the persons profile page (eg, by using $_GET on the ID field and then fetching all the data you need from the row matching that ID. you get the location of the image, which you then echo out into a <img src="" /> tag.
There you have it.
User Profile Avatars
You probably know how to upload an image (im sure jacek has covered this) And im sure you know how to insert data into a database, and how to fetch data and how to echo out data.
You have everything you need there.
When you upload the image, make sure you upload it to a certain location where they are all stored, and make sure the file name is unique (good technique for this is often just the timestamp, however for popular websites, adding a salt and md5ing it will make it completely unique.
This data you then store into the database alongside the user profile data (in the same row as the person it corresponds to. For the image you store the location on the server from root. Eg. /profile/images/image0123133131.jpg
When you fetch that data on the persons profile page (eg, by using $_GET on the ID field and then fetching all the data you need from the row matching that ID. you get the location of the image, which you then echo out into a <img src="" /> tag.
There you have it.
User Profile Avatars
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: User Profile Avatar
Yes...but i was thinking on a user gallery, and the option for the user to select from that gallery the profile picture.( Select picture as profile pic)...that's not the same as uploading a user profile image...and not everyone knows how to do it, that's why it will be a good and useful tutorial..bowersbros wrote:Its fairly simple.
You probably know how to upload an image (im sure jacek has covered this) And im sure you know how to insert data into a database, and how to fetch data and how to echo out data.
You have everything you need there.
When you upload the image, make sure you upload it to a certain location where they are all stored, and make sure the file name is unique (good technique for this is often just the timestamp, however for popular websites, adding a salt and md5ing it will make it completely unique.
This data you then store into the database alongside the user profile data (in the same row as the person it corresponds to. For the image you store the location on the server from root. Eg. /profile/images/image0123133131.jpg
When you fetch that data on the persons profile page (eg, by using $_GET on the ID field and then fetching all the data you need from the row matching that ID. you get the location of the image, which you then echo out into a <img src="" /> tag.
There you have it.
User Profile Avatars
Regards.
Re: User Profile Avatar
That wont actually add any more uniqueness. What you are doing to the timestamp is always the same, so the resulting value is still only dependant on the input.bowersbros wrote:adding a salt and md5ing it will make it completely unique.
Also, I will add this to the list
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: User Profile Avatar
Where i said salt, i meant random string ;Djacek wrote:That wont actually add any more uniqueness. What you are doing to the timestamp is always the same, so the resulting value is still only dependant on the input.bowersbros wrote:adding a salt and md5ing it will make it completely unique.
Also, I will add this to the list
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9