Create a table with BLOB field, a sample table can be this
- CREATE TABLE `images` (
-
`id` int(11) NOT NULL auto_increment,
-
`image` blob NOT NULL,
-
PRIMARY KEY (`id`)
-
) ENGINE=MyISAM;
Then read the image file, encode and store in the BLOB field as in the example below.
[PHP]$image = chunk_split(base64_encode(file_get_contents("image .jpg")));
$qry = "INSERT INTO images (image) VALUES('$image')";
mysql_query($qry) or die(mysql_error());[/PHP]
And to display the image, use this code
[PHP]header('Content-type: image/jpeg');
$rs = mysql_fetch_array(mysql_query("SELECT image from images where id=1"));
echo base64_decode($rs["image"]);[/PHP]
But make sure there must not be any sort of output before header().
Why you want to store the images in the DB?