1

我希望附加文件存在于 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);
4

1 回答 1

1

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

尝试这个:

$targetFile = fopen($dir.$dirName.'/movie.flv', 'a');
于 2013-08-06T11:37:05.707 回答