我使用CURL复制文件:
$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);
问题是,当文件很大(超过3Mb)时,服务器最终会得到一个大小为0Kb的文件。所以我的问题是......为什么CURL不会复制大文件以及我缺少什么来修复它?
答案 0 :(得分:0)
尝试将输出直接发送到文件:
curl_setopt($ch, CURLOPT_FILE, $fp);