title: Yii2 uploaded image doesn't display
body: <p>So I've set a CRUD to upload a file to the server's root, in a folder called 'uploads'.
  Now, the file is properly saved in the particular folder and the database entry appears to be alright - but the images don't display in the CRUD's 'index' and 'view' actions. Any thoughts on this one? </p>
  
  <p>Create:</p>
  
  <pre><code>    public function actionCreate()
      {
          $model = new PhotoGalleryCategories();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
  
              $model-&gt;image = UploadedFile::getInstance($model, 'image');
  
              if (Yii::$app-&gt;ImageUploadComponent-&gt;upload($model)) {
                  Yii::$app-&gt;session-&gt;setFlash('success', 'Image uploaded. Category added.');
  
                  return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
              } else {
                  Yii::$app-&gt;session-&gt;setFlash('error', 'Proccess could not be successfully completed.');
  
                  return $this-&gt;render('create', [
                      'model' =&gt; $model
                  ]);
              }
  
          } else {
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
              ]);
          }
      }
  </code></pre>
  
  <p>ImageUploadComponent file:</p>
  
  <pre><code>&lt;?php 
  
  namespace app\components;
  
  use Yii;
  use yii\base\Component;
  use yii\base\InvalidConfigException;
  
  class ImageUploadComponent extends Component {
  
      public function upload($model) {
  
          if ($model-&gt;image) {
  
              $imageBasePath = dirname(Yii::$app-&gt;basePath, 1) . '\uploads\\';
              $imageData = 'img' . $model-&gt;image-&gt;baseName . '.' . $model-&gt;image-&gt;extension;
  
              $time = time();
  
              $model-&gt;image-&gt;saveAs($imageBasePath . $time . $imageData);
  
              $model-&gt;image = $imageBasePath . $time . $imageData;
  
              if ($model-&gt;save(false)) {
                  return true;
              } else {
                  return false;
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>And the index file for the views:</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\grid\GridView;
  
  /* @var $this yii\web\View */
  /* @var $searchModel app\modules\admin\models\PhotoGalleryCategoriesSearch */
  /* @var $dataProvider yii\data\ActiveDataProvider */
  
  $this-&gt;title = 'Photo Gallery Categories';
  $this-&gt;params['breadcrumbs'][] = $this-&gt;title;
  ?&gt;
  &lt;div class="photo-gallery-categories-index"&gt;
  
      &lt;h1&gt;&lt;?= Html::encode($this-&gt;title) ?&gt;&lt;/h1&gt;
      &lt;?php // echo $this-&gt;render('_search', ['model' =&gt; $searchModel]); ?&gt;
  
      &lt;p&gt;
          &lt;?= Html::a('Create Photo Gallery Categories', ['create'], ['class' =&gt; 'btn btn-success']) ?&gt;
      &lt;/p&gt;
  
      &lt;?= GridView::widget([
          'dataProvider' =&gt; $dataProvider,
          'filterModel' =&gt; $searchModel,
          'columns' =&gt; [
              ['class' =&gt; 'yii\grid\SerialColumn'],
  
              'name',
  
              'image' =&gt; [
                  'attribute' =&gt; 'image',
                  'value' =&gt; 'image',
                  'format' =&gt; ['image', ['class' =&gt; 'col-md-6']]
              ],
  
              ['class' =&gt; 'yii\grid\ActionColumn'],
          ],
      ]); ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/4e16C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4e16C.png" alt="enter image description here"></a></p>
  
  <p>Edit: In the dev tools, I can see the correct source for the image. What's more, I can access it by copy-pasting the address in the browser. (the first rows are images taken from the internet through their address, they are not saved locally.)</p>