问题描述
如何使用php从bytea字段加载img标签中的图片?我正在使用postgresql数据库
我尝试过:
<?php
//连接数据库
$ con_qupos = pg_connect('host = 192.168.60.254 dbname = dbqupos user = postgres password = 12345')或死(pg_last_error());
//获取bytea数据
$ res = pg_query('select foto fromschSuperCristian.articulo_foto其中codigo_referencia ='。'''8711600305960');
$ raw = pg_fetch_result($ res,'foto');
//转换为二进制并发送到浏览器
header('Content-type:image / jpeg');
echo pg_unescape_bytea($ raw);
?>
how can I load a picture in a img tag from bytea field, using php? I´m using postgresql database
What I have tried:
<?php
// Connect to the database
$con_qupos = pg_connect('host=192.168.60.254 dbname=dbqupos user=postgres password=12345') or die(pg_last_error());
// Get the bytea data
$res = pg_query('select foto from "schSuperCristian".articulo_foto where codigo_referencia='."'8711600305960'");
$raw = pg_fetch_result($res, 'foto');
// Convert to binary and send to the browser
header('Content-type: image/jpeg');
echo pg_unescape_bytea($raw);
?>
推荐答案
这篇关于如何使用PHP从bytea字段加载img标记中的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!