Forum Moderators: coopster
function imagepng2string($im)
{
$contents = ob_get_contents();
if ($contents!== false) ob_clean(); else ob_start();
imagepng($im);
$data = ob_get_contents();
if ($contents!== false)
{
ob_clean();
echo $contents;
}
else ob_end_clean();
return $data;
}
$data = addslashes(imagepng2string($im));
now $data is formatted properly to be inserted into a mysql table.
Buffering the output is a viable option. However, you should use mysql_real_escape_string() [php.net] to insert binary data rather than addslashes.