Se rendre au contenu
Menu
Cette question a été signalée
4303 Vues

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 ?

Avatar
Ignorer
Publications associées Réponses Vues Activité
2
mars 18
5785
0
mars 15
4145
3
mai 24
5800
4
juil. 23
4741
1
sept. 20
2862