Open Authorized File and Stream it to Output
<p>I'm trying to use examples on stackoverflow but cannot find anything that will work in PHP.  I'm trying to stream a large file from a server but then in real time stream it to the output in PHP.  The thing is I cannot seem to accomplish it because the file needs authorization.  I have the credentials because it's my home server.  Has anyone accomplished this?</p>

<pre><code>$ch = curl_init();
$writefunc = function($ch, $chunk) {
    print $chunk;
    ob_flush();
    flush();
    return len($chunk);
};
curl_setopt($ch, CURLOPT_BUFFERSIZE, 8096);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch,CURLOPT_WRITEFUNCTION , $writefunc);
curl_exec($ch);
</code></pre>
