Hansmagz Hansmagz - 2 months ago 5
CSS Question

How to make two different folder get resources from one folder?

I have a dynamic about page

About Page

<section class="page">

<header style="background-image: url('uploads/<?php echo $page[header_picture]; ?>'); background-position: center;"></header>

<div class="container">

<?php echo $page['body_formatted']; ?>

</div>




and the Admin page

Admin Page

They both have same the same src

uploads/1473747556216.jpg


but my admin page are in a Admin folder.

How to make two different folder get resources from one folder?

Answer

Each file would need to either provide an absolute or relative path to the source file.

If your directory structure is:

root
    about.php
    admin
        admin.php
    uploads
        1473747556216.jpg

Then relative paths would be:

"uploads/1473747556216.jpg" // from about.php
"../uploads/1473747556216.jpg" // from admin.php

Then absolute paths would be:

"http://whatever.com/uploads/1473747556216.jpg" // for either file

Then relative from root (if supported in your environment):

"/uploads/1473747556216.jpg" // from either file
Comments