Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to read out image_small (bytea) from hr_employee and pass to imagecreatefromstring (php)

By
Christian Eichert
on 2/13/14, 9:05 PM 887 views

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 ?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/13/14, 9:05 PM
Seen: 887 times
Last updated: 3/16/15, 8:10 AM