Danny620 Posted June 24, 2009 Share Posted June 24, 2009 Hello i need to know how to create a script that can get someones picture from a file or db and display it like a avatar. this is what i think i will do please corrent me if i am wrong build a image up-loader when the image is uploaded store it in a var and the insert it into the db using a username from a log-in session. << that's the one i think will work but i don't have a clue about the file method where it gets uploaded to a file on the server and then is displayed when the user is logged in. Quote Link to comment https://forums.phpfreaks.com/topic/163489-image-upload/ Share on other sites More sharing options...
MadTechie Posted June 24, 2009 Share Posted June 24, 2009 options #1. upload image to a folder, rename it to the usersID.jpg then have a field in the uers table called avatar set to usersID.jpg #2. store the image in a blob in the database and then create a php file to emulate the image, ie <?php header('Content-Type: image/jpeg'); //connect to database $SQL = sprintf("SELECT Image FROM table WHERE userid=%d LIMIT 1",$_GET['id']); $r = mysql_query($SQL); $row = mysql_fetch_row($r); echo $row['Images']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/163489-image-upload/#findComment-862609 Share on other sites More sharing options...
Danny620 Posted June 24, 2009 Author Share Posted June 24, 2009 THANK YOU i didn't think it would be that simple i have only just started learning php over asp.net i am only sixteen and looking to get a job as a php program er you have just helped me to get even close now 1 more question is it safe to use session for getting users profile and pictures and things Quote Link to comment https://forums.phpfreaks.com/topic/163489-image-upload/#findComment-862616 Share on other sites More sharing options...
947740 Posted June 24, 2009 Share Posted June 24, 2009 Yes. In fact, one of the better ways. Quote Link to comment https://forums.phpfreaks.com/topic/163489-image-upload/#findComment-862618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.