アップロードされた画像を yii2 で postgres データベースから取得する際に問題があります
その方法で画像をデータベースに保存します:
$data = pg_escape_bytea(file_get_contents($model->CheckIfAvatarExists(Yii::$app->user->identity->username)));
$profile->passphoto = new Expression("'{$data}'");
$profile->save();
画像を完璧に保存
しかし、画像を表示しようとすると、機能しません:
header('Content-type: image/png');
echo pg_unescape_bytea( $profile->passphoto);
大きな問題は、エスケープされた後のデータが元に戻らないことだと思います。
解決策はありますか?