I have a profile page which contains the upload file from this tutorial...and there's a link on the profile page saying 'Upload avatar'! When I upload a new picture...the avatar in profile doesn't change! :/ The image is saved in the AVATARS folder but isn't shown in profile....
Can you tell me how to change the profile picture when a person uploads a new picture.
I have got everything working except the very end put which is displaying the image.
It doesn't seem to like my below bit. I get the error:
"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in [location to line of IF statement below]" if (mysql_num_rows($query2) == 0)
@BenLancaaster have you any registration form for new user? you can set default image in query that creates one than use script from this tutorial, in phpmyadmin I can't set default value too...
Warning: move_uploaded_file(../users/avatars/avatar.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Users/Muhammad_Osama/Sites/Project B/PHP/signup.php on line 73
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phpcTPNyQ' to '../users/avatars/avatar.jpg' in /Users/Muhammad_Osama/Sites/Project B/PHP/signup.php on line 73
@TheOsama1994@kalipsso1 Create folders within the avatar folder that corresponds to the user's id. These folders can be made automatically after registration. Then just change the $location to the correct directory using the proper valuables.
I've made the base of my script using this tutorial. I've also sorted out how to manage filenames so they won't mess up when two files have the same name. They are named after the ID of the user who uploads it. The only problem what stands is that people are still able to upload images with weird proportions so it wont fit in as an avatar picture.
If you have time for it, will you maybe make an extention to this tutorial? I loved it!
Hey alex, i've been following yo image upload series but i was making mine a music upload site and i want to display the login success at the profile page and not at the registration page. i want the user to see the login success msg in their profile and not keep seeing the regstrtn form. help?
Just wondering if anyone else has had the problem with the "User not found" error? If so / or not, could you look at my code and see if you find anything odd about the code?
Did you have problems with the error "User not found" showing up? I can't seem to get past that error unless I take out the mysql_num_rows from the (query)==0 part. But then I only have a blank box show up with no image........
i love you tutorials, they really do help a lot, i was wondering, if you could show a way of changing a profile picture and it overwrites the image in FTP because many people would like this feature. and also viewing other peoples profiles would be huge
you could make another page altogether, like a unique profile page for each unique user, and echo that user's avatar onto their profile page so all can see.
what happens if a user uploads an image with the same name?
MrSethmcfarlane 1 week ago
Works awesome I added a user profile image to my site! Your PHP tutorials are very useful and cool!
TerrierToby 2 weeks ago
This has been flagged as spam show
muito bom, mesmo nao sabendo inglês entendi muito, parabéns!
wagnerspfc2011 2 weeks ago
muito bom, mesmo nao sabendo inglês entendi muito, parabéns!
wagnerspfc2011 2 weeks ago
Thanks A Lot! :D
I Have A Question.
I have a profile page which contains the upload file from this tutorial...and there's a link on the profile page saying 'Upload avatar'! When I upload a new picture...the avatar in profile doesn't change! :/ The image is saved in the AVATARS folder but isn't shown in profile....
Can you tell me how to change the profile picture when a person uploads a new picture.
xxTechWiZxx 1 month ago
Comment removed
xxTechWiZxx 1 month ago
Anyone having an issue with the end bit..?
"Hey :)
I have got everything working except the very end put which is displaying the image.
It doesn't seem to like my below bit. I get the error:
"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in [location to line of IF statement below]" if (mysql_num_rows($query2) == 0)
xbriskx 1 month ago
@xbriskx make sure this is what you have in ur query ..... WHERE username='$username'");
hisroyalawesomeness 1 month ago
Great tutorial, i managed to get it all working!
But how can i set a default image for users who haven't set an image?
I tried to set it as the default in phpmyadmin but it does work :(
Help would be great!
BenLancaaster 2 months ago
@BenLancaaster have you any registration form for new user? you can set default image in query that creates one than use script from this tutorial, in phpmyadmin I can't set default value too...
quiteflame 2 months ago
Perfect! Thanks so much :)
bentoms 2 months ago
THANKS A LOT!!!!! very helpful for starters like me and for those who are developing their 1st dynamic website using PHP!
ianungas05 2 months ago
great tut ! gud job alex !
neilrockz1 3 months ago
This has been flagged as spam show
Hi, Alex,thanks it worked perfect , but how about this: $_SESSION['username']="alex"; I have to do like this:$_SESSION['username']; or how?
DZBrahim 3 months ago
@DZBrahim Ok ! Alex I did it Thankx a lot.
DZBrahim 3 months ago
I get this when i try uploading :
Warning: move_uploaded_file(../users/avatars/avatar.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Users/Muhammad_Osama/Sites/Project B/PHP/signup.php on line 73
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/Applications/XAMPP/xamppfiles/temp/phpcTPNyQ' to '../users/avatars/avatar.jpg' in /Users/Muhammad_Osama/Sites/Project B/PHP/signup.php on line 73
TheOsama1994 7 months ago
@TheOsama1994 I just didnt had full rights to the folder :D
TheOsama1994 7 months ago
what if two users have a same image name when they upload it??
TheOsama1994 7 months ago
@TheOsama1994 @kalipsso1 Create folders within the avatar folder that corresponds to the user's id. These folders can be made automatically after registration. Then just change the $location to the correct directory using the proper valuables.
ndm250 6 months ago
I've made the base of my script using this tutorial. I've also sorted out how to manage filenames so they won't mess up when two files have the same name. They are named after the ID of the user who uploads it. The only problem what stands is that people are still able to upload images with weird proportions so it wont fit in as an avatar picture.
If you have time for it, will you maybe make an extention to this tutorial? I loved it!
sacrome 7 months ago
Hello Alex do you have any examples of how to create school class schedule in php?
vampmasterangelus1 8 months ago
What happens if two users upload a file with the same name?
Lets say "alex" uploads a file with name "avatar.jpg" and "kyle" uploads a file with the name "avatar.jpg".
It will mess up their avatars...
kalipsso1 9 months ago
@kalipsso1
in ur mysql query you would specify a UNIQUE value using the primary key (id) field he included..
OllieGee333 8 months ago
@kalipsso1 could be fixed by changing the name to md5("random string").jpg
daeheadshot 8 months ago
nice tutorial
Driglou 10 months ago
Hey alex, i've been following yo image upload series but i was making mine a music upload site and i want to display the login success at the profile page and not at the registration page. i want the user to see the login success msg in their profile and not keep seeing the regstrtn form. help?
TheDigiTaw 10 months ago
What if two users have the same name of a file?
rokec5555 11 months ago
Thank you so much! your tutorials are the best!
Helenlovesrivers 1 year ago
Just wondering if anyone else has had the problem with the "User not found" error? If so / or not, could you look at my code and see if you find anything odd about the code?
Thanks :O)
aaronmisty08 1 year ago
Comment removed
Mag3llan 1 year ago
very helpful, thanks!
beef267 1 year ago
Hi Alex, thanks for this great script :) Makes my site look allot more presentable and personal for the user!
bloodthirst666220 1 year ago
Just noticed that when adding .png in the end in location does as the file gets converted to a .png while even if it's .gif or .jpg
xXZarlachXx 1 year ago
I made as the script saves as "Username.png" in that way it will overwrite your previous image, instead one user having tons of uploaded images.
This is what i did:
$location = "avatar/$session->username.png";
$session->username displays the username i'm logged in as, your "display-username-script" may be different.
xXZarlachXx 1 year ago
Thanks for the videos! I it wasn't that easy to make it work, i had to edit some scripts, but it works!
The script i was having problems with is the picture display script, but this is how it ended up working:
<img src="<? echo $req_user_info['avatar'];?>">
(Request the source from the php script that looks at my mysql table named 'avatar', and convert it into a direction (avatar/image.png)
it even worked when viewing another member profile's picture when logged in to another account
xXZarlachXx 1 year ago
@xXZarlachXx
Did you have problems with the error "User not found" showing up? I can't seem to get past that error unless I take out the mysql_num_rows from the (query)==0 part. But then I only have a blank box show up with no image........
aaronmisty08 1 year ago
@aaronmisty08
I meant mysql_num_rows from the ($query)==0
aaronmisty08 1 year ago
Thanks so very much for this! You've helped me out tremendously! ^_^
theswordqueen 1 year ago
i really like your tutorials ...hope you do more ...tnx
jaymiemartin 1 year ago
hi alex..you are such a great teacher..i just want to ask you if you can upload a video about how to view a friends profile..just like in FS or FB..
thanks in advance..
this will help me alot..
philyow060391 1 year ago
@philyow060391 ya good idea i really want to know how to do that too because im creating a social network.
speedysb100 1 year ago
East or west alex are the best of the best........hi alex i m from india.......your tutorials help me a lot
gurpreet471 2 years ago 2
Hi alex,
i love you tutorials, they really do help a lot, i was wondering, if you could show a way of changing a profile picture and it overwrites the image in FTP because many people would like this feature. and also viewing other peoples profiles would be huge
TheSquiblo 2 years ago
Alex im encountering a major problem.
When i apply this on my image sharing site
I couldnt register another account anymore
and i could only log in with the user that i typed in my upload.php What do you think is wrong ? Please help me.....
TheEpisode21 2 years ago
i'm willing to bet you forgot to destroy sessions :)
lashtal 2 years ago
how can i test if an image exist?
evermanito 2 years ago
helpful thanks
fauzi84 2 years ago
Fantastic tutorial!
Thanks a lot Alex!
omanoman98 2 years ago
How can i show other users my avatar ?
Timzy921 2 years ago
you could make another page altogether, like a unique profile page for each unique user, and echo that user's avatar onto their profile page so all can see.
lashtal 2 years ago
lol yea, now i know how, i learned how to make a community-like forums but its pretty easy for me now :) thnx thou
Timzy921 2 years ago
thanks =D it worked perfect :)
Timzy921 2 years ago
thanks! really cool :) all your tutorials are helping me a lot to do my thesis!!!
ikiOchoa 2 years ago