I have saved images in mysql db using this code
migration file
'content' => 'LONGBLOB NOT NULL',
controller file
$model->content = file_get_contents($model->path);
$model->save(false);
in view file and its works fine
echo '<img src="data:image/jpeg;base64,'.base64_encode($model->content).'"/>';
in gridview
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'content',
'format' => ['html'],
'filter' => false,
'value' => function ($data) {
if (!empty($data['content'])) {
return Html::img(Yii::getAlias( $data['content'] )
,['data:image/jpeg;base64'=>'.base64_encode']
);
}
return "Not choosen";
},
],
['class' => 'yii\grid\ActionColumn'],
],
]);
?>
but there is nothing appearing