yii2 display image (basic tamplate)

My project

My operations system (OP) is a linux ubuntu desktop.


Options +FollowSymLinks

IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule . index.php

in web folder i created a picture folder.

in picture folder-> BMW.jpg



use yii\helpers\Html;

use yii\widgets\ActiveForm;

use yii\helpers\Url;

use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */

$this->title = ‘My Yii Application’;


   &lt;img src='&quot;.Yii::&#036;app-&gt;request-&gt;baseUrl.&quot;/picture/BMW.jpg'&gt;

   &lt;?php echo Url::to('/picture/BMW.jpg'); ?&gt;

   &lt;?php echo Html::img(Yii::&#036;app-&gt;params['baseUrl'] .'/web/picture/BMW.jpg', ['width'=&gt;'350','height'=&gt;'200'],['alt' =&gt; 'alt image']);?&gt;

   &lt;?php echo Html::img('picture/BMW.jpg') ?&gt;

   &lt;?php echo Html::img('@web/picture/pic.jpg') ?&gt;

Does not work! Why?

Thanks for your help!

And this?

<?php echo Html::img(\Yii::$app->homeUrl.'/picture/BMW.jpg', ['width'=>'350','height'=>'200'],['alt' => 'alt image']);?>

does not appear, the picture,

My htaccess is not good?

chmod -R 755 picture

I solved,

Run this chown -R www-data.www-data yourprojectdirectory .

Run this from var/www/html,not inside project.