Years back I read the pros and cons of storing pictures in a database
(column type blob) against storing them on the file system, and I always
thought storing pictures in the database blob is a better option. But I have
never seen a clean example of how to programmatically insert the picture
(binary file) into the db table. 

The example on MySQL forum is discussing using the use of MySQL Query
Browser to manually insert each picture into a database and that is not
possible when the large number of pictures is involved or when users are to
upload pictures using a web form.

http://forums.mysql.com/read.php?20,17671,27914#msg-27914


Today I found few PHP examples which are pretty what I was looking to do. 

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-m
ysql-database.aspx
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-m
ysql-database.aspx 


But then I came across this a compelling idea not to load pictures into
MySQL blob as it makes it difficult to manage when images are large and
especially not worthwhile when moving a large database to another server or
backup and restore in case of database failure. I will now store by pictures
in the  file system and the file names in the database. Anyone interested
should read inserting pictures into MySQL database may want to first read
this page: http://hockinson.com/index.php?s=37


Cheers 


=> -----Original Message-----
=> From: Dr.Ruud [mailto:rvtol+use...@isolution.nl]
=> Sent: 22 July 2010 07:52
=> To: beginners@perl.org
=> Subject: Re: Example code for storing picture in MySQL DB
=> 
=> Mimi Cafe wrote:
=> >
=> >  $dbh->do(qq{insert into mytable (id, pic)
=> values(1,$pic_file_name)});
=> >
=> >
=> > Any experience on this?
=> 
=> This is not clear: do you want to store the contents, or the
=> (complete?)
=> file name?
=> 
=> The BIGBLOB type is fine for storing contents. These values are stored
=> outside the row data space, so need extra IO, and that is good.
=> You can process the blob in chunks to limit overhead.
=> 
=> To store the filename, use a VARCHAR(1000) with the proper CHARSET.
=> 
=> --
=> Ruud
=> 
=> --
=> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
=> For additional commands, e-mail: beginners-h...@perl.org
=> http://learn.perl.org/
=> 



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to