2016-12-31 43 views
0

一个HTML图像元素。当我浏览“本地主机/项目名/用户”,然后我得到一个用户帐户图像像产生在CakePHP中

enter image description here

但是当我浏览“本地主机/项目名/用户/添加”然后我得到一个用户帐户图像像

enter image description here

但我想看到正确的图像的所有操作。

我的代码如下。

<a href="#" class="dropdown-toggle" data-toggle="dropdown"> 
    <img src="img/penguen.jpg" class="user-image"> 
    <?php $this->User = ClassRegistry::init('User');?> 
    <span class="hidden-xs"> 
     <?php if (AuthComponent::user('id')): ?> 
     <?= AuthComponent::user('username') ?> 
     <?php endif; ?> 
    </span> 
</a> 
+0

是你'用户'文件夹中的'img'文件夹,像这样'localhost/ProjectName/users/img /'? – EhsanT

+0

app/webroot/img/imagename这是我的图片链接 –

+0

您在评论中提供的路径与您在问题中的路径没有任何共同之处! – EhsanT

回答

2
<img src="img/penguen.jpg" class="user-image"> 

是你的错。

杠杆助手为您生成“有效”链接,问题就迎刃而解了:

$this->Html->image('penguen.jpg', ['class' => 'user-image']); 

切勿使用手册一的img标签与内置手动网址​​,只能出问题。