无法将照片添加到 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。没有任何帮助
这是保存图像的示例代码,但在 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());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)