Relative paths resolve base on the current working directory of the request. This will change from request to request depending on what php file initially received the request. What you need to do is to make this into a absolute path.
There are several techniques that you can use for this. The __DIR__
magic constant is one of the more useful but for your problem, since you know what the path it relative to the document root you can do this.
$last_mod = filemtime($_SERVER["DOCUMENT_ROOT"]."/images/file.png");
This uses your web server's document root to give you a starting point to resolve your path against (the file system path equivelent to the http://mysite.com url).
__DIR__
is useful if you want to resolve a path relative to the path that the __DIR__
constant is used in. On earlier php versions you can use dirname(__FILE__)
to get the same value.