【问题标题】:Images are not displaying in my view [closed]图像未显示在我的视图中[关闭]
【发布时间】:2014-10-16 06:51:53
【问题描述】:

这是我的视图文件:-

<h1>Welcome <?php echo "$username " ?> </h1>
<h3>
<?php echo "your User Id is: $id "?></br>
<?php echo "your User name is: $username "?></br>
<?php echo "your Password is: $password"?></br>
<?php echo "your Profile picture is: $image"?></br>
</h3>
<img src="../files/<?php echo $image ?>" alt="Profile picture" width="100" height="130">

我的文件夹在应用程序文件夹之外。

【问题讨论】:

  • 您是否为$image 获得了价值?
  • 查看您的浏览器控制台,如果图像没有丢失或输入错误(错误 404)
  • 是的,我得到了 $image 的价值............
  • 请详细说明你的文件结构..你可能没有得到图像路径。
  • $image 的值是多少,该图像放在服务器上的什么位置(文件夹结构)?

标签: php html image codeigniter


【解决方案1】:

改变

<img src="../files/<?php echo $image ?>" alt="Profile picture" width="100" height="130">

<img src="http://localhost/CodeIgniter_2.2.0/files/<?php echo $image ?>" alt="Profile picture" width="100" height="130">

【讨论】:

    【解决方案2】:

    在查看图片之前使用$this-&gt;upload-&gt;data() helper and [full_path] =&gt; /path/to/your/upload/jpg.jpg上传图片

    【讨论】:

      【解决方案3】:

      我没有得到你的文件夹结构,考虑到我开始时的错误,请使用 base_url();

      <img src="<?php echo base_url(); ?>/path/to/image/from_web_app_root">
      

      确保在使用前加载它。

      这是链接:https://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

      【讨论】:

        【解决方案4】:

        如果您的 /application/config/autoload.php 文件中没有加载 URL 帮助程序,请通过 $this->load->helper('url'); 在控制器中加载 URL 帮助程序; 然后编写如下代码:

        <img src="<?php echo base_url(); ?>files/<?php echo $image ?>" alt="Profile picture" width="100" height="130">
        

        【讨论】:

          猜你喜欢
          • 2013-06-09
          • 2012-05-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-03-23
          • 1970-01-01
          相关资源
          最近更新 更多