Downloading big files and writing it locally
<p>which is the best way to download from php large files without consuming all server's memory?</p>

<p>I could do this (bad code):</p>

<pre><code>$url='http://server/bigfile';
$cont = file_get_contents($url);
file_put_contents('./localfile',$cont);
</code></pre>

<p>This example loads entry remote file in <code>$cont</code> and this could exceed memory limit.</p>

<p>Is there a safe function (maybe built-in) to do this (maybe stream_*)?</p>

<p>Thanks</p>
