请问大家:如何将图片以二进制形式保存进mysql的blob型字段中?
我用了以下代码,但除了二进制字段外,其余字段值正常保存了,二进制字段值缺为空:(后台用select语句查询出的)
$fileinfo=$_FILES['attfile'];
$file_name = $fileinfo['name'];
$file_newname=$fileinfo['tmp_name'];
  $temp_a=fread(fopen($file_newname,"r"),filesize($file_newname));
  $filecontent=addslashes($temp_a);
  $sql='insert into tablename(img) values("'.$filecontent.'")';  
$rst=$conn->execute($sql);显示:

$strId=$_GET['ID']; //记录ID
$strTb=$_GET['TB']; //表名称
$strGraphFn=$_GET['GRAPHNAME']; //图片字段名称
$strIdFn=$_GET['KEYNAME']; //KEY字段名称

$sql='select '.$strGraphFn.' from '.$strTb.' where '.$strIdFn.'='.$strId;
$temp_graph_content= $conn->execute($sql);
if(!($temp_graph_content==null || $temp_graph_content->RecordCount()==0))
{
$temp_img=imagecreatefromstring(stripslashes($temp_graph_content[$strGraphFn]));
if ($temp_img!=false)
{
Header( "Content-type: image/gif"); 
imagegif($temp_img);
imagedestroy($temp_img);
}else
{
echo 'An error occurred.';
}
}else
{
echo "";
}
显示出错。