I have several files in my web folder, including these two:
where somesubdir is a symbolic link to another directory on my disk, to a path named, eh, let's say /anywhere/else.
Inside include.inc.php, something like this is written:
<?php
require_once "../settings.inc.php";
?>
In my opinion, that should include /mydocroot/include/settings.php... But guess what happens: PHP tries to include /anywhere/settings.inc.php, instead of /mydocroot/include/settings.inc.php.
It seems like PHP automatically resolves symbolic links.
How can I avoid this and include my settings.inc.php file?
There is no command to retarget a symbolic link, all you can do is remove it and create another one. The rename command's -s option will "rename a symbolic link target, not the symbolic links itself". It will also operate on multiple symbolic links at once.
<input type="file" name="upload_captcha_background" id="upload_captcha_background" /> var file_path= jQuery("#upload_captcha_background"). val(); alert(file_path);
I just had a similar issue. You can do it by using $_SERVER['SCRIPT_FILENAME']
variable, that displays the requested file, so in your case it will be /mydocroot/include/somesubdir/include.inc.php
, even if somesubdir
is a symbolic link. To include a file that is one level lower instead of doing
require_once "../settings.inc.php";
do this:
require_once dirname(dirname($_SERVER['SCRIPT_FILENAME'])).DIRECTORY_SEPARATOR."settings.inc.php"
Documentation about $_SERVER
variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With