Mapping Absolute / Relative (Local) Paths to Absolute URLs
- by Alix Axel
I need a fast and reliable way to map an absolute or relative local path (say ./images/Mafalda.jpg) to it's corresponding absolute URL, so far I've managed to come up with this:
function Path($path)
{
if (file_exists($path) === true)
{
return rtrim(str_replace('\\', '/', realpath($path)), '/') . (is_dir($path) ? '/' : '');
}
…