Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在html[yii2]中显示绝对路径图像_Html_Css_Yii2 - Fatal编程技术网

如何在html[yii2]中显示绝对路径图像

如何在html[yii2]中显示绝对路径图像,html,css,yii2,Html,Css,Yii2,我可以参考像这样的照片 但是我不想在网站路径中保存用户数据图像,所以我尝试在中找到test.jpg /home/www/userdata/username/test.jpg 但是不能引用它的abs路径,当在html上显示图片时,图片没有显示,如下所示: <img src="/home/www/userdata/username/test.jpg"/> 我指出,我不想将用户数据存储在webroot中,也不想将其存储在数据库中 在这种情况下,webroot和userdata位于

我可以参考像这样的照片

但是我不想在网站路径中保存用户数据图像,所以我尝试在中找到test.jpg

/home/www/userdata/username/test.jpg
但是不能引用它的abs路径,当在html上显示图片时,图片没有显示,如下所示:

<img src="/home/www/userdata/username/test.jpg"/>

我指出,我不想将用户数据存储在webroot中,也不想将其存储在数据库中

在这种情况下,webroot和userdata位于同一目录:/home/www/(www用作用户名)

我是否需要wirte和图像服务器,以便通过http引用图像


欢迎提供任何建议~

您的HTML页面位于何处

如果位于www中,则您可以使用以下内容:

<img src="userdata/username/test.jpg"/>

否则,请在开始前删除“/”:

<img src="home/www/userdata/username/test.jpg"/>


/home/www是usrdata和yiiWebroott的共同父亲dir。请尝试以下方法:在“home”之前删除“/”