简体   繁体   中英

yii2 image not loading in html img tag but showing in browser

I am using yii2 and storing the image in root folder images. I have pointed the new domain to image folder and its working fine also in browser images are getting upload also showing in a browser but when I am trying to use them in IMG tag than it is not showing.

for ref please check below url http://image.letspartii.com/advertisement/oJ9LFcAk2azVuGAHUrb8iyuuLqMJjUYa.png

1 - All images you want to display must be stored inside the /web folder.

2 - Use the relative path to call the img (starting inside de /web).

3 - Make sure to have the correct permission to the img folder and the file inside /web (permission and web/apache group).

Use the Url::base() method to get relative path:

<img src="<?= yii\helpers\Url::base().'/img/'.$filename; ?>"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM