View Full Version : save image in mysql database
atimmohd
10-30-2002, 06:24 AM
hai...
can i store an image inside mysql database?
if can, please show me..
tanks
Hazhir
12-16-2007, 05: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
}
StupidRalph
12-16-2007, 05: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.
nysmenu
07-28-2009, 02: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, 08: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.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.