Storing images in mysql database
Mysql database can be used to store images, in other words as an image library. You ‘ll store the data using a “blob” type here.
At first read the image as byte format then store. if image length is less than 149000, then it can be done.
sample coding
$instr = fopen(”image.jpg”,”rb”);
$image = addslashes(fread($instr,filesize(”image.jpg”)));
if (strlen($instr) < 149000) {
mysql_query (”insert into pix (title, imgdata) values (”Image”, \”".$image.”\”)”);
} else {
$errmsg = “Too large!”;
}
