如何使用PHP从bytea字段加载img标记中的图片 [英] How can I load a picture in a img tag from bytea field, using PHP

查看:100
本文介绍了如何使用PHP从bytea字段加载img标记中的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用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);
?>

推荐答案

con_qupos = pg_connect('host = 192.168.60.254 dbname = dbqupos user = postgres password = 12345')或死(pg_last_error());



//获取bytea数据
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 fromschSuperCristian.articulo_foto where codigo_referencia ='。''8711600305960' );
res = pg_query('select foto from "schSuperCristian".articulo_foto where codigo_referencia='."'8711600305960'");


raw = pg_fetch_result(
raw = pg_fetch_result(


这篇关于如何使用PHP从bytea字段加载img标记中的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆