上傳文件
在后臺(tái)的controller里引入use yii\web\UploadedFile;? 后臺(tái)有創(chuàng)建和更新文件操作飘哨,都需要引入上傳文件的代碼敦冬。并且上傳的圖片保存在web目錄下面的uploads/flow/文件下徐块。上傳文件的目錄存到數(shù)據(jù)庫(kù)中吠撮。
如果在后臺(tái)Imgs那顯示圖片可以這樣改:
[
? ? 'attribute' => 'imgs',
? ? 'format' => [
? ? ? ? 'image',
? ? ? ? ? ? ? [
? ? ? ? ? ? ? ? ? ? 'width'=>'50',
? ? ? ? ? ? ? ? ? ? 'height'=>'50'
? ? ? ? ? ? ? ]
? ? ],
? ? 'value' => function ($model) {
? ? ? ? return $model->imgs?$model->imgs:'http://t.ynet.cn/images/ms-icon-70x70.png';
? ? },
]