Download file with cURL

PHP code to download file with cURL
<?php
/*
This is usefull when you are downloading big files, as it
will prevent time out of the script :
*/
set_time_limit(0);
ini_set(‘display_errors’,true);//Just in case we get some errors, let us know….

$fp = fopen (dirname(__FILE__) . ‘/kho/phungvanhuy.txt’, ‘w+’);//This is the file where we save the information
$ch = curl_init(‘http://huypv.net/blog/i.htm’);//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);//can be warned
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>