src/Control/HTTP.php
public static function filename2url($filename)
    {
        $filename = realpath($filename);
        if (!$filename) {
            return null;
        }

        // Filter files outside of the webroot
        $base = realpath(BASE_PATH);
        $baseLength = strlen($base);
        if (substr($filename, 0, $baseLength) !== $base) {
            return null;
        }

        $relativePath = ltrim(substr($filename, $baseLength), '/\\');
        return Director::absoluteURL($relativePath);
    }
public static function filename2url($filename)
    {
        $filename = realpath($filename);
        if (!$filename) {
            return null;
        }

        // Filter files outside of the webroot
        $base = realpath(BASE_PATH);
        $baseLength = strlen($base);
        if (substr($filename, 0, $baseLength) !== $base) {
            return null;
        }

        $relativePath = ltrim(substr($filename, $baseLength), '/\\');
        return Director::absoluteURL($relativePath);
    }
public static function filename2url ( $ filename ) { $ filename = realpath ( $ filename ) ; if ( ! $ filename ) { return null ; } // Filter files outside of the webroot $ base = realpath ( BASE_PATH ) ; $ baseLength = strlen ( $ base ) ; if ( substr ( $ filename , 0 , $ baseLength ) !== $ base ) { return null ; } $ relativePath = ltrim ( substr ( $ filename , $ baseLength ) , '/\\' ) ; return Director :: absoluteURL ( $ relativePath ) ; }
Turns a local system filename into a URL by comparing it to the script filename.

@param string $filename
@return string
Turns a local system filename into a URL by comparing it to the script filename .