View Full Version : save image in mysql database

10-30-2002, 07:24 AM
can i store an image inside mysql database?
if can, please show me..

12-16-2007, 06:19 AM
Take look :

sub addNews {
my $self = shift;
my $file = param('new_pic'); #this is a Image File

undef $file_cont;
binmode $file;
binmode $file_cont;
while (<$file>){
$file_cont .= $_;
my $sql = "INSERT INTO sys_news
SET Image= ". $self->{SQL}->quote($file_cont).", CreateDate=NOW()";
$self->{SQL}->do($sql); # this means $dbh->do($sql); :D

12-16-2007, 06:35 AM
You can save a picture inside a DB but as several threads here suggest its usually better to save the PATH to the image file instead. Try using the search function to find some of those old threads.

07-28-2009, 03:42 PM
how do you save the PATH? I've created a field for images in my form but, I can't cut and paste the file name to include. Any suggestions? Thanks

Wizzard of Jazz
12-21-2010, 09:57 AM
Use input field of type file. The file is sent to the server as $_FILES. var dump this and you'll be a long way.