
Here is a code in PHP with cURL, that can download a remote file and save it.
<?php set_time_limit(0); $fp = fopen ('myfile.tar', 'w+'); $url = "http://www.example.com/file_name.tar"; $ch = curl_init(str_replace(" ","%20",$url)); curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); ?>
The CURLOPT_FILE option takes a file resource and writes the content of the URL to that file resource/handle. Also set the script time limit to a large extent so that the script carries on while downloading a large file. That's all.
0 comments