简单的CURL副本不起作用?

I am using CURL to copy files:

$ch = curl_init ($copyMe);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9");
$rawdata=curl_exec($ch);
curl_close ($ch);
$fp = fopen($toTarget,'x');
fwrite($fp, $rawdata);
fclose($fp);

The problem is, the moment the file is big (over 3Mb), the server ends up with a file of size 0Kb. So my questions is.... why does CURL not copy large files and what am I missing to fix this?

Try to send output directly to file:

curl_setopt($ch, CURLOPT_FILE, $fp);