$data = file('image.gif'); will not work because that's asci based.
use fopen(), fread() and fclose() to fill up $data
then
PHP Code:
mysql_query("INSERT INTO table VALUES ('".mysql_real_escape_string($data)."')");
Works perfectly on my system
for output of the data use
PHP Code:
header('Content-type: image/gif');
echo $data;