Uploading / Storing Photos

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Tue Nov 02, 2010 7:15 am

Uploading / Storing Photos

Postby cfsamet » Tue Nov 09, 2010 3:41 pm

I need some general information to get started.

I have a site I'm working on as a project - consider it a mini-facebook or something if you need a reference. Users register, have profiles, etc.

I need to be able to allow users to upload photos. My question - should I be uploading the photos and storing them in mysql, or (and I assume this is the better option) uploading them to the file system, and referencing them in mysql?

Assuming the second is the better option, can anyone point me in a direction to get started?

Any thoughts would be appreciated. Thanks.


User avatar
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Uploading / Storing Photos

Postby egami » Thu Nov 11, 2010 10:52 am

the second is the better option.

in your images table, just have a field where you can reference your user and their pictures.
for example..

/var/www/images/mysite/* is your images directory.

your mysql table is called images
table has the following fields..
img_id, img_userid,img_name,img_uploaded
img_id is your key
img_userid is your key to assoc the user
img_name is the name of the file uploaded into the /var/www/images/mysite directory
img_uploaded is the datetime stamp when it was actually uploaded.

Then you can map the links of the photos, call them whenever needed, etc.etc.etc.

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest