Created
August 3, 2016 10:51
-
-
Save azharisubroto/41acf7ce0169d7da013d9d03078d7c49 to your computer and use it in GitHub Desktop.
This code snippet is useful to copy a large file from other server and store it to your server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
//This is the file where we save the information | |
$fp = fopen (dirname(__FILE__) . '/filename.rar', 'w+'); | |
//Here is the file we are downloading, replace spaces with %20 | |
$ch = curl_init(str_replace(" ","%20", 'http://someserver.crot/filename.rar')); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 50); | |
// write curl response to file | |
curl_setopt($ch, CURLOPT_FILE, $fp); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
// get curl response | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment