我将图像存储在MySql数据库Blob字段中。当我试图将它们拉回来时,我得到的图像并不起作用。如果我将它存储错误或者只是我保存它的方式有任何线索吗?
if($_FILES['damage001']['tmp_name']){
$data = file_get_contents($_FILES['damage001']['tmp_name']);
$data = mysql_real_escape_string($data);
$photo1_type = protect($_POST['photo1_type']);
$photo1_desc = protect($_POST['photo1_desc']);
$sql = "INSERT into `tbl_osd_attachments` SET
`osd_id`='$id',`picture`='$data',`type`='$photo1_type', description = '$photo1_desc';";
$query = mysql_query($sql) or die(mysql_error());
//echo 'link to uploaded picture: <a href='.$url.'> Picture link! </a>';
}else{ echo '<br><br>';}
拉动图片的代码:
$z2=mysql_result($result_pics,$z,"picture");
echo "<img alt='embedded image' src='data:image/png;base64,".base64_encode($z2)."' >";
我正在从mysql切换到mysqli