We have a problem retrieving uploaded image from postgres database with yii2
we store image with that way to the db:
$data = pg_escape_bytea(file_get_contents($model->CheckIfAvatarExists(Yii::$app->user->identity->username)));
$profile->passphoto = new Expression("'{$data}'");
$profile->save();
stores image perfectly
but when we try to display image, it is not working:
header('Content-type: image/png');
echo pg_unescape_bytea( $profile->passphoto);
I think the big problem is data after escaped it wont back to original be unescape
Any solutions?