title: Create absolute url from relative url in drupal
body: <p>I have created an update script in <strong>hook_update_N</strong> where I have to create relative urls from absolute url.</p>
  <p><em>For eg :</em></p>
  <p><code>relative url = /files/test1.jpg</code></p>
  <pre><code>absolute url should be http://localhost.mysite/files/test1.jpg
  </code></pre>
  <p>I know these possible solutions,</p>
  <ul>
  <li>file_create_url()</li>
  <li>url()</li>
  <li>$_SERVER['host'], $_SERVER['server_name']</li>
  </ul>
  <p>But none of them is working in the update script.</p>
  <p><em>Possible Reason</em> : Script isn't executed from browser. So there isn't request from which you can resolve server name etc.</p>
  <p>The above solutions work fine if I run the script from browser instead of terminal.</p>
  <p>Is there any other way we can create absolute urls in hook_update_N so that it works when I run the script from terminal?</p>