附加文件,不覆盖

时间:2013-08-06 10:18:51

标签: php curl download

我希望追加文件存在,在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);

1 个答案:

答案 0 :(得分:0)

CURLOPT_FILE的文件处理程序标记为“只读”。

试试这个:

$targetFile = fopen($dir.$dirName.'/movie.flv', 'a');
相关问题