doudu2404 2018-04-16 10:19
浏览 32
已采纳

包含具有不同文件夹的文件

I like to use php-include for the first time to include different partials within my static webpages. My folder structure is something like that:

-index.php
-other.php
----production
-------partials
-----------partial1.php
----public
-------images
-----------image1.png

And I want to reference the image from my partial1.php. So I try to do

<img src="../../public/images/image1.png">

but the reference doesn't work and I can add or delete as many "../" as I want, still not working. How else would I define a path to my public-folder and reference to that correctly?

  • 写回答

1条回答 默认 最新

  • doutan8506 2018-04-16 10:24
    关注

    Try insert full path:

    <img src=\"<?php echo @getcwd()."/public/images/image1.png" ?>\" />
    

    or add other ../:

    <img src="../../../public/images/image1.png">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)