List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:November 16 2006 4:00pm
Subject:RE: Contents storing in mysql
View as plain text  
This work has to be done in a client, since you have to manage external
files. If the files are all uniquely named, then you could use filename as a

In my case, I was linking the images to a product in another table. I used
three tables:

prod_num /* an auto-increment key */
... /* other product specific information */

image_num /* an auto-increment key */
original_image_name /* a key varchar field */
... /* other information about uploaded images, such as file type (.jpg,
.gif) */

prod_num /* a key, holds the product number from prod_table */
image_num /* a key, holds the image number from image_table */

Then I name each image the same as its image_num, regardless of its original
name. That avoids any collisions, and allows two images with the same
original name to coexist. When someone uploads an image that goes with a
specific product, I add a record to image_table and prod_image_index and
store the file. If a product is deleted, I can easily find and delete the
related image files when I delete the entries in prod_image_index.

If someone wants to see the images for a particular product, I find them in
prod_image_index. I follow the image_num back to image_table to get the
original file name for the user's convenience. I can then display the image
file (/imgs/1234, say) along with its original_file_name.

If the user then chooses to delete an image, then I delete the file
(/imgs/1234), the corresponding record in image_table, and the corresponding
records in prod_image_index.

I hope that helps.


Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

> -----Original Message-----
> From: Shain Lee [mailto:gsm_linux@stripped]
> Sent: Thursday, November 16, 2006 5:52 AM
> To: MySql
> Subject: Contents storing in mysql
> Hi ,
> I wanted to store images , musics, videos ..etc in mysql
> database.storing contents as content type BLOB  , i  don't
> have any issues with that setup.
> But ,   now i need to store that contents in folders and
> should be kept the contents path with referrence of
> contents file name .
> for eample , if i have a image called  sky.jpg . and that
> image stored in the /usr/local/wallpapers/sky.jpg.
> In  my database , i have defined fields like , filename ,
> filesize, imagepath, contenttype.
> How can i do that ?
> can you give me any help ful links ?
> Thanx in advance,
> Shaine.
> ---------------------------------
>  All New Yahoo! Mail - Tired of Vi@gr@! come-ons? Let our
> SpamGuard protect you.

Contents storing in mysqlShain Lee16 Nov
  • RE: Contents storing in mysqlJerry Schwartz16 Nov
  • Re: Contents storing in mysqlcolbey16 Nov