/** * get file url * * @param string $value * @return string */ function getFileUrl($value) { $output = ''; $wwwroot = removeTrailingSlash(backslashToSlash(getRootPath())); $urlprefix = ""; $urlsuffix = ""; $value = backslashToSlash(getRealPath($value)); $pos = stripos($value, $wwwroot); if ($pos !== false ) { $output = $urlprefix . substr($value, $pos + strlen($wwwroot)) . $urlsuffix; }else { $output = $value; } $protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' ? 'https' : 'http'); return $protocol . "://" . addTrailingSlash(backslashToSlash($_SERVER['HTTP_HOST'])) . removeBeginingSlash(backslashToSlash($output)); }
/** * get file url * * @param string $value * @return string */ function getFileUrl($value) { $output = ''; $wwwroot = removeTrailingSlash(backslashToSlash(getRootPath())); $urlprefix = ""; $urlsuffix = ""; $value = backslashToSlash(getRealPath($value)); $pos = stripos($value, $wwwroot); if ($pos !== false && $pos == 0) { $output = $urlprefix . substr($value, strlen($wwwroot)) . $urlsuffix; }else { $output = $value; } return "http://" . addTrailingSlash(backslashToSlash($_SERVER['HTTP_HOST'])) . removeBeginingSlash(backslashToSlash($output)); }