[code]
function get_path_from_url($url) {
$temp = explode(‘/’, trim($url, ‘/’));
$cnt = count($temp);
$path = $temp[count($temp)-1];
for ($i=$cnt-1; $i>=0; $i–) {
$path = $_SERVER[“DOCUMENT_ROOT”].DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, array_slice($temp, $i));
if (is_dir($path) || is_file($path)) {
return $path;
}
}
return false;
}
[/code]
사용법
[code]
$url = ‘http://hacktam.kr/data/39485575758273.jpg’;
$path = get_path_from_url($url);
echo $path; // /home/hacktam/www/data/39485575758273.jpg
[/code]