allow users to post photos

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
kristie380
Forum Commoner
Posts: 36
Joined: Sun Oct 09, 2005 10:51 pm

allow users to post photos

Post by kristie380 »

Hi - I run a high school alumni website and I really want to allow my registered users to upload a picture of themselves to be included with their profiles. Their profiles are stored in MY SQL so I would need to have them upload their pictures to the database. Then I would need a script to call the picture from the database and format it. I have done a lot of research on the internet for scripts to help me but I can't seem to find anything that works. Can someone PLEASE help me? Thanks!
Last edited by kristie380 on Wed Feb 15, 2006 3:51 pm, edited 1 time in total.
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

an alternative would be to upload the images to a pics/ directory, a structure like this:


/path/to/site/pics/username.jpg

and then when you load their page you check

if( file_exists( "/path/to/site/pics/username.jpg" ) )
... display the image ...

If this sounds appeal, let me know and I can help further
kristie380
Forum Commoner
Posts: 36
Joined: Sun Oct 09, 2005 10:51 pm

Post by kristie380 »

so when they upload their picture, how do i change the name of the image (we'll say it's "1234.gif") to be their username - "username.gif" so that i can call up the picture?
kristie380
Forum Commoner
Posts: 36
Joined: Sun Oct 09, 2005 10:51 pm

Post by kristie380 »

and how would i re-size it to a thumbnail size?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

kristie380 wrote:so when they upload their picture, how do i change the name of the image (we'll say it's "1234.gif") to be their username - "username.gif" so that i can call up the picture?
To answer this, read http://php.net/features.file-upload
Something to look at is move_uploaded_file()
kristie380 wrote:and how would i re-size it to a thumbnail size?
there are several thumbnail scripts available on the forums here. At least one is in Code Snippets.
Post Reply