Jump to content

Recommended Posts

Hi I am getting problems linking to files within different folders....

 

can some one explain the following ../ as i thought that should direct to the root folder

 

I have root/admin/db/inc/file.php

 

and am trying to link to the css in the following...

 

in that file i want to require config.php

 

which is located root/inc/config.php

 

so i assumed (as i dont wish to put the full URL in - incase some other site wants to use the code) that you could do it like so...

 

require("../inc/config.php");

 

But this is not working!

 

Anybody got any solutions or explain further how ../ works??

 

thanks

 

d

Link to comment
https://forums.phpfreaks.com/topic/52786-requirefilephp-linking-problem/
Share on other sites

I can't make heads or tails of the full text above, but to answer the question of what "../" is:

 

It's a link, meaning "one dir up". Actually only the the dots are the link.

 

. "this dir"

 

.. "one dir up"

 

The first ("this dir") is added to the include path in default php.ini configuration, that is why you are able to omit paths when including files in the same directory.

 

For relative HTTP links in HTML I recommend you make all links relative to the site root, example: "/img/pic.jpg", "/css/default.css".

when ever I use include or require I start with $_SERVER['DOCUMENT_ROOT'] and specify a full path.  So far it has helped prevent and malicious attacks on file includes when the include is dependant on user input.....

 

 

when ever I use include or require I start with $_SERVER['DOCUMENT_ROOT'] and specify a full path.  So far it has helped prevent and malicious attacks on file includes when the include is dependant on user input.....

 

Data in the $_SERVER array is not necessarily to be trusted. Better to manage include_path and utilize open_basedir.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.