[英]Get blob image from MySQL by using Node as json and print it into PHP
[英]Can't get blob transparent image into json using php
if (function_exists($_GET['displayResult']))
displayResult();
function displayResult() {
$db = new PDO('sqlite:ROS.sqlite');
$sql = 'select * from Item_Image_Large';
$result = $db->query($sql);
$rows[] = array();
while ($row = $result->fetchObject()) {
$rows['Item_Image_Large'][] = $row;
foreach ($rows as $key => $value) {
$newArrData[$key] = $rows[$key];
$newArrData[$key]['image_large'] = base64_encode($rows[$key]['image_large']);
}
}
header('Content-type: image/png');
$result2 = json_encode($newArrData);
echo $result2;
}
此代码用于从数据库中获取BLOB数据,并尝试将其转换为JSON格式,但不起作用。 BLOB数据为PNG格式。
更改
header('Content-type: image/png');
至
header('Content-Type: application/json');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.