我以下面的方式在SQL DB,varbinary(max)数据类型的图像字段中保存了一个图像。如何在SQL Server中存储和检索图像VARBINARY(MAX)数据类型
$image = "baby.jpg";
$type = pathinfo($image, PATHINFO_EXTENSION);
$data = file_get_contents($image);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$insert = "insert into logoType(image)values(?)";
$param = array($base64);
$sql = sqlsrv_query($dbhandle, $insert, $param) or die(print_r(sqlsrv_errors()));
插入部分成功。现在,我怎样才能从数据库中检索保存的图像,并使用php将其显示在网页中。我尝试了以下方法,但不断收到错误消息,“图像无法显示,因为它包含错误。”
header('Content-Type: image/x-bmp');
echo $image;
如何使用PHP中的数据存储在数据库中的图像显示在网页?请指导。提前致谢。