Daiaiai
Daiaiai

Reputation: 1089

Include a file with a different folder

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?

Upvotes: 0

Views: 49

Answers (1)

user8108122
user8108122

Reputation:

Try insert full path:

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

or add other ../:

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

Upvotes: 1

Related Questions