title: Yii2: How to display Image in View using image path saved in database?
body: <p>Trying to display image in view:</p>
  
  <p><code>id_image</code> holds image path in db.By using path need to display image.
  Tried with following code but it not showing any image. </p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-xs-6 col-md-3"&gt;
      &lt;a href="#" class="thumbnail"&gt;
        &lt;img src="&lt;?php $dataProvider-&gt;models[0]-&gt;id_image; ?&gt;"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>public function actionView($id)
      {
           $searchModel = new CreateBookingsSearch();
          $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
          return $this-&gt;render('view', [
              'model' =&gt; $this-&gt;findModel($id),
              'dataProvider' =&gt; $dataProvider,
              'searchModel' =&gt; $searchModel,
          ]);
      }
  </code></pre>
  
  <p>Create/Upload File in Controller</p>
  
  <pre><code>public function actionCreate()
      {
          $model = new CreateBookings();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()))
          {
              $imageName = $model-&gt;first_name;
              $mobile = $model-&gt;primary_mobile;
              $model-&gt;file = UploadedFile::getInstance($model, 'file');
              $model-&gt;file-&gt;saveAs( 'uploads/id_images/'.$imageName.'_'.$mobile.'.'.$model-&gt;file-&gt;extension);
              //save the path in the db column
              $model-&gt;id_image = 'uploads/id_images/'.$imageName.'_'.$mobile.'.'.$model-&gt;file-&gt;extension;
  
              $model-&gt;save();
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          } else {
              return $this-&gt;render('create', [
                  'model' =&gt; $model,
              ]);
          }
      }
  </code></pre>
  
  <p>Path Example saved in db:</p>
  
  <pre><code>uploads/id_images/kumar_9015879992.jpg
  </code></pre>