Set_time_limit (0);
Supports all file types
//URLs here:
$url = ' http://somsite.com/some_video.flv ';
$pi = PathInfo ($url);
$ext = $pi [' extension '];
$name = $pi [' filename '];
Create a new CURL resource
$ch = Curl_init ();
Set URL and other appropriate options
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_header, false);
curl_setopt ($ch, Curlopt_binarytransfer, true);
curl_setopt ($ch, Curlopt_autoreferer, true);
curl_setopt ($ch, curlopt_followlocation, true);
curl_setopt ($ch, Curlopt_returntransfer, true);
Grab URL and pass it to the browser
$opt = curl_exec ($ch);
Close CURL resource, with free up system
curl_close ($ch);
$saveFile = $name. $ext;
if (Preg_match ("/[^0-9a-z._-]/i", $saveFile))
$saveFile = MD5 (Microtime (TRUE)). $ext;
$handle = fopen ($saveFile, ' WB ');
Fwrite ($handle, $opt);
Fclose ($handle);