PDA

View Full Version : Storing a reference to an image's location


misterx
04-09-2004, 10:59 PM
If you insist on storing the actual image file in the database ( I recommend against it) then make sure you set the datatype to BLOB.

As to your earlier question it can't really be explained better with a sample script. All you need to do is insert strings (varchar datatype) into the database. The strings you store will be the file name and the path to the image ie. ( "image.jpg" and "/home/images/" ). You would store the actual image file in some directory. All you store in the database is the information necessary to find the image.

I don't know how I could possibly explain that any more clearly.
__________________
Spookster
Moderator PHP Forum
All Hail Spookster

I have a question about this particular method. In storing strings with references to the location of the image file, would you have seperate columns for path and file name? If so, why? I'm curious as to if there is any benefit to having seperate path and file name columns as opposed to simply having one column which just stores the path with the filename on the end.

Thanks.

raf
04-09-2004, 11:15 PM
I'm not sure what the question is ... I mean, both approaches have advantages and there are situations imaginable where each of them is the best sollution.
So it depends a bit on your requirements what the best approach is ...

misterx
04-09-2004, 11:58 PM
Ok, just wondering. Thanks. :D

Huggy
04-23-2004, 01:35 PM
Separating data gives greater flexibility.

For example having the directory in one column and filename in another enables you to select all records where the directory is the same, or count the number of directories by counting the unique entries in the directory column.

Hope this is of some help.