当我使用PostgreSQL(来自带有PHP mysqli-connector的MySQL)将Web应用程序转换为ODBC时,我目前遇到了一个奇怪的问题。
我注意到在PostgreSQL数据库中存储为bytea
并投入到PHP的base64函数中的图像未正确显示。在某些时候它被切断了几行之后。这个截断时间是我们数据库中存储的所有bytea
图像数据,我们有用于徽标和签名的图像数据。
如果您使用浏览器的检查员检查img标记,您会看到(至少在Chrome中)该图片的大量数据丢失。
我做的是SELECT * FROM table
,然后在for循环中将图像编码为base64:
$clients[$i]['logo'] = base64_encode($clients[$i]['image']);
$clients[$i]['image'] = this is the bytea in the database and
$clients[$i]['logo'] = this is the base64 String that I display in a Smarty template like this: data:image/png;base64,{$client.logo}
我希望你能提供帮助。
答案 0 :(得分:0)
解决方案是odbc.ini文件中的数据长度。如果长度有限,那么太长的base64字符串将被切断。只需要增加尺寸。