2012-10-30 50 views
0

使用Curl(Philip Sturgeon)库使用CURLOPT_FILE下载文件是可行的吗?使用卷曲库的CURLOPT_FILE

现在我使用的,它的工作原理,但我想用curl库做到这一点:

set_time_limit(0); 
ini_set('display_errors',true);//Just in case we get some errors, let us know.... 

$fp = fopen ('/Users/tony/labs/store/'. 'a.mp4', 'w+');//This is the file where we save the information 
$ch = curl_init($previewUrl);//Here is the file we are downloading 
curl_setopt($ch, CURLOPT_TIMEOUT, 50); 
curl_setopt($ch, CURLOPT_FILE, $fp); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_exec($ch); 
curl_close($ch); 
fclose($fp); 

我想是这样的:

$file = fopen($to, 'w'); 
$this->curl->create($url); 
$this->curl->option('file', $file); 
$this->curl->execute(); 
fclose($file); 

回答

1

我认为使用一个包装了库本身已经非常简单的卷曲只是矫枉过正。

如果它不支持它,库只是一个single.php文件,你可以很容易地在那里添加一行代码,它会支持它。