Forum Moderators: coopster

Message Too Old, No Replies

How to store images?

standard upload or blob style in db?

         

kkonline

2:08 pm on Sep 14, 2007 (gmt 0)

10+ Year Member



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?

vincevincevince

3:09 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



auto_increment column in the table for image_id.
At upload, store the [type] of the image, and the [name] in the database.
$insertid=mysql_insert_id();
move_uploaded_file($_FILES[file][tmp_name],"storeimages/".$insertid);

Now, you have everything you need to retrieve the image (mime type and name) and you know where it's stored (by row ID)