How to execute imagepng() function with yii2?

In another plain-Php-application, following code will render png-file using php code like this:


<img src="counter.php" title="Pic1" alt="Picture1">

counter.php is in folder /frontend/views/site. counter.php uses php-functions like imagecreatefrompng(), imagepng() etc.picture is in folder:




$gfx_file = Yii::getAlias('@web') . '/img/tacho.png'; 

In my plain application, picture will be shown as being presented at my attachement counter.png. In my yii2-application, picture won’t be found. Any ideas how to fix this circumstance?

Your 2 lines of code are not enough to give any help oder advice.

How to “execute” it? You call it as you normally would. Using Yii does not prevent you from using PHP’s built-in functions.

The first thing you should do is actually validate the whole path being stored in $gfx_file, do a file_exists check on it.