first create the table
create table images (
image_id serial,
filename varchar(255) not null,
mime_type varchar(255) not null,
file_size int not null,
file_data longblob not null,
primary key (image_id),
index (filename)
);
the file to output the images to the browser picsrc.php
<?PHP
//detect if image is called correctly
if($image){
//connect to db
$db = mysql_connect('localhost', 'user', 'password');
//find the image
$query = sprintf('select * from images where filename = %d', $image);
$result = mysql_query($query, $db);
$image = mysql_fetch_array($result);
//tell the browser the url is an image
header('Content-type: ' . $image['mime_type']);
header('Content-length: ' . $image['file_size']);
//finally output the image
echo $image['file_data'];
}
?>
to call the image use this line
<img src="picsrc.php?image=potato.jpeg">
fairly straightforward. you can view a full tutorial at http://www.effectivewebdesign.co.nz/tutorial.php
hope this helps.