Converting from server image URL to absolute address
<p>I guess this is a simple question but I really can't find anything that would help me.</p>

<p>I'm using an image download script and for that I need an image URL that looks like:
"/home/clients/websites/w_apo/public_html/apo/wp-content/uploads/2012/05/Beautiful.jpg"
[type1]</p>

<p>but what I have is:
"http://www.apo.com/wp-content/uploads/2012/05/Beautiful.jpg"
[type2]</p>

<p>I tried to write a function that returns the URL of type 1 to the URL of type 2 but it doesn't work all that great.
This is how it looks:</p>

<pre><code>function relativeToServerAddress($relativeURL) {
    $paths = explode('wp-content/', $relativeURL);
    $thePath = getcwd()."/wp-content"."/".$paths[1];
    return $thePath;
}
</code></pre>

<p>Is there any better way to do this? I tried to find a predefined function but failed.</p>

<p>Thanks</p>
