Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4291 Переглядів

How can I read out image_small (bytea) from hr_employee and pass to imagecreatefromtext (php) ?

// Performing SQL query
$dbconn = pg_connect("  host='".PGSQL_HOST."' 
                        port='".PGSQL_PORT."' 
                        dbname='".PGSQL_DBNAME."' 
                        user='".PGSQL_USER."' 
                        password='".PGSQL_PASSWORD."' ")or die('Could not connect: ' . pg_last_error());

$query='SELECT image_small 
        FROM hr_employee 
        WHERE id='.$im;

$result = pg_query($dbconn, $query) or die('Query failed: ' . pg_last_error());
$arr = pg_fetch_array($result);

$im=$arr['image_small']);

and now I have the string Then I tryed like this

$img = imagecreatefromstring($im);
if ($img !== false) {
    header('Content-Type: image/png');
    imagepng($img);
    imagedestroy($img);
}

say that the image cannot be displayed because it contains errors

any suggestions please ?

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
бер. 18
5766
0
бер. 15
4138
3
трав. 24
5795
4
лип. 23
4735
1
вер. 20
2860