【问题标题】:Error 403 Image not found in Drupal 7在 Drupal 7 中找不到错误 403 图像
【发布时间】:2017-07-27 11:11:33
【问题描述】:

我从配置中创建了一个块。在这个块里面,我写了这段代码……

 <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(禁止访问)
我整天都在努力寻找解决方案。但是,我仍然无法解决。
谁能帮帮我?

【问题讨论】:

  • 提供图片的完整url并检查图片是否存在
  • localhost:8888/drupal/sites/all/themes/myancast/images/ios.png .. 这是完整的图像路径兄弟。图像存在兄弟。我得到了这个错误。您无权访问此服务器上的 /drupal/sites/all/themes/myancast/images/ios.png。我将 chmod 777 更改为图像文件夹以及其中的所有图像兄弟。但是,不工作:(

标签: php image drupal-7 localhost http-status-code-403


【解决方案1】:

在您的代码中添加全局 $base_url 并像下面这样使用

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

【讨论】:

    【解决方案2】:

    你试过了吗?

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

    【讨论】:

      【解决方案3】:

      试试这个,

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-16
        • 2010-11-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多