Skip to content

Instantly share code, notes, and snippets.

@subrotoice
Created September 30, 2017 07:57
Show Gist options
  • Save subrotoice/643fa77791b4a459a7e48ec7af67efdb to your computer and use it in GitHub Desktop.
Save subrotoice/643fa77791b4a459a7e48ec7af67efdb to your computer and use it in GitHub Desktop.
//Download File form server to server
<?php
set_time_limit(0); //Unlimited max execution time
$path = 'latest.zip'; //can keep this name same
$url = 'https://wordpress.org/latest.zip';
$newfname = $path;
echo 'Starting Download!<br>';
$file = fopen ($url, "rb");
if($file) {
$newf = fopen ($newfname, "wb");
if($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
echo '1 MB File Chunk Written!<br>';
}
}
if($file) {
fclose($file);
}
if($newf) {
fclose($newf);
}
echo 'Finished!';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment