2017-07-27 98 views
0

我从配置中创建一个块。这里面块,我写这篇文章的代码...错误403在Drupal 7中找不到图像

<div class="provider-bg" id="provider1"> 
     <img alt="" class="img-responsive" src="<?php echo base_path().path_to_theme() ?>/images/provider-1.jpg" /> 
</div> 

然后,我保存PHP文本格式。

我的虚拟主机是... http://localhost:8888/drupal
所以,图像路径会是这样......

<img alt="" src="/drupal/sites/all/themes/myancast/images/ios.png"> 

此图片显示在过去数天前。今天,我运行该网站,该图像立即消失,并得到403错误。

无法加载资源:服务器响应状态为403(禁止)
我试图在整天找到解决方案。但是,我仍然无法解决。
任何人都可以帮助我吗?

+0

提供图像的完整URL,并检查图像的存在与否 –

+0

的http://本地主机:8888/Drupal的/网站/所有/主题/ myancast/images/ios.png ..这是完整的图像路径bro。图像存在兄弟。我有这个错误。您无权访问此服务器上的/drupal/sites/all/themes/myancast/images/ios.png。我将chmod 777更改为图像文件夹以及其内部的所有图像。但是,不工作:( –

回答

2

加入全球$ BASE_URL在你的代码,并使用如下

<img alt="" class="img-responsive" src="<?php echo $base_url.'/'.path_to_theme(); ?>/images/provider-1.jpg" /> 
+0

不工作兄弟.... –

1

你尝试呢?

<img alt="" class="img-responsive" src="<?php echo '/'.path_to_theme(); ?>/images/provider-1.jpg" /> 
0

试试这个,

<?php 
 
$imgurl = file_create_url(path_to_theme().'/images/provider-1.jpg'); 
 
?> 
 
<img alt="" class="img-responsive" src="<?php echo $imgurl ?>"/>