简体   繁体   English

无法使用PHP将blob透明图像导入json

[英]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;
}

This code is used for get BLOB data from database and try to convert it into JSON format but it doesn't work. 此代码用于从数据库中获取BLOB数据,并尝试将其转换为JSON格式,但不起作用。 The BLOB data is in PNG format. BLOB数据为PNG格式。

change 更改

header('Content-type: image/png');

to

header('Content-Type: application/json');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM