如何在 php 中添加 blob 图像 FIrebird?

How to add blob image FIrebird in php?

无法将照片添加到 FIrebird。写这样一段代码

        $imgSrc='Desert.jpg';
    $img_src = $imgSrc;
    $imgbinary = fread(fopen($img_src, "r"), filesize($img_src));
    $img_str = base64_encode($imgbinary); 

    $blh = ibase_blob_create($this->db);   
    ibase_blob_add($blh, $img_str);
    $blobid = ibase_blob_close($blh);

    $row = false;
    /*$fd = fopen('Desert.jpg', 'r');
    $blob = ibase_blob_import($fd);
    fclose($fd); */
    $query = ibase_query($this->db, "INSERT INTO \"ud_ab\" (FILES) VALUES (?)", $img_str ) or die(ibase_errmsg());
    if($query) $row = true; 
    return $row;

尝试翻译base64格式的图片,写了ibase_blob_add.Nothing帮助

这是保存图像的示例代码,但在 blob 字段中

define('MAX_SEGMENT_SIZE', 65535);

function blob_create($data) {
    if (strlen($data) == 0)
        return false;
    $handle = ibase_blob_create();
    $len = strlen($data);
    for ($pos = 0; $pos < $len; $pos += MAX_SEGMENT_SIZE) {
        $buflen = ($pos + MAX_SEGMENT_SIZE > $len) ? ($len - $pos) : MAX_SEGMENT_SIZE;
        $buf = substr($data, $pos, $buflen);
        ibase_blob_add($handle, $buf);
    }
    return ibase_blob_close($handle);
}
$blob = blob_create(file_get_contents('Desert.jpg'));
$query = ibase_query($this->db, "INSERT INTO \"ud_ab\" (FILES) VALUES (?)", $blob) or die(ibase_errmsg());