realpath returns empty string

16.6k views Asked by At

I use MediaWiki but there is an error. I found it in the files. There is line with this code:

$IP = realpath( '.' );

But $IP returns an empty string, so the path to the files in the system is not working. (for example if $IP would be . or E:/path_to_wwwroot it works). How can I solve the problem. Is it possible that my provider blocked access to realpath?

Thanks!

3

There are 3 answers

4
Alexey Morozov On BEST ANSWER

Source: http://php.net/manual/en/function.realpath.php

Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

So your web server should have access also to pre-webroot directories.

0
Alberto M On

The path I was creating didn't exist, make always sure that it's well formed.

This is the path I was using:

realpath(MY_PATH . '../other_path');

Where MY_PATH didn't have a trailing /.

0
siliconrockstar On

I am currently experiencing this result when running PHP from command line, but not within an HTTP request. Got to be config or $_SERVER settings somewhere, will update if I find the fix.