// common.php提供$dbconn
require_once('Common/common.php');
// 要获取的图片,此处只是 示例用, 应该是自动从某网页获取的url 【】
$url = 'http://localhost/images/index.jpg';
$handle = fopen ($url, "rb");
// 读取图片内容
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while(true);
fclose ($handle);
// Image 是 bytea类型,数据库postgrest, 用pg_escape_bytea 转换为bytea
$SQL = 'Update "Bl_Image" set "Image"='."'".pg_escape_bytea($contents)."'".' where "ChaseNo"='."'112'";
// echo $SQL;
pg_exec($dbconn, $SQL);
pg_close($dbconn);