0
我想追加文件,然後存在,在CURL下載功能,不覆蓋。我使用這段代碼,但它不起作用。請幫幫我。追加文件,不覆蓋
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
if(isset($_GET['resumedownload'])){
if (file_exists($dir.$dirName.'/movie.flv')) {
$targetFile = fopen($dir.$dirName.'/movie.flv', 'r');
curl_setopt($curl, CURLOPT_INFILE, $targetFile);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 3600);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:9.0.1) Gecko/20100101 Firefox/9.0.1");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_REFERER, $file);
curl_setopt($curl, CURLOPT_COOKIEFILE,'cookie.txt');
curl_setopt($curl, CURLOPT_NOPROGRESS, false);
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, 'progressCallback');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FILE, $targetFile);
curl_exec($curl);
fclose($curl);
爲CURLOPT_FILE您的文件處理程序與 '只讀' 標記。這是故意的嗎? –
謝謝大人! –
現在保存該文件,但仍覆蓋舊文件,應附加到它。 –