How to store images?

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
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

How to store images?

Post by kkonline »

I have around 500 images each of 70 to 100kb. I want to store it on the webserver.

I can store it by directly uploading it (standard way we do it) or can upload to database as medium blob.
The upside of storing the images in database is that i can easily have number of views and rating using table fields but i have been suggested by many friends that storing on database using blob is not preferable.

Then how do i store the images?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Just store the filename in a db table and make reference to the image on server via dir path when you want to display it.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

In my opinion, using DB storage would greatly eliminate the concurrency problems with file names. But I would say that this is its only advantage :)
There are 10 types of people in this world, those who understand binary and those who don't
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Post by aliasxneo »

aceconcepts wrote:Just store the filename in a db table and make reference to the image on server via dir path when you want to display it.
I would do this as well. If you're worried about file names just generate a long random string, md5/substr it and attach it to the end of each image. Then just include the random code/file name in the database.
elinews
Forum Commoner
Posts: 38
Joined: Tue Aug 14, 2007 7:18 pm

Post by elinews »

Why not just pull the files directly from the directory?
Post Reply