you can look at this example
$fp = fopen (dirname(__FILE__) . '/downloaded/my_file', 'w+');
$ch = curl_init('http://server.where.interesting/file.resides.com/123.doc');
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp)
pay attention to the curl_setopt() http://gt.php.net/manual/en/function.curl-setopt.php
optionally, at the begin of the script you can set
set_time_limit(0); // to prevent timeout for big file download
ini_set('display_errors',true);//useful for debug purposes