Created
June 4, 2015 17:50
-
-
Save Feyisayo/dc0e1f4690e7e0363a52 to your computer and use it in GitHub Desktop.
This script is useful in downloading files unto a webserver.
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 | |
// Enter URL of file to download here. | |
$f = 'https://wordpress.org/latest.tar.gz'; | |
$dest_file = fopen (basename($f), "w"); | |
if (!$dest_file) { | |
echo "<p>Error: Unable to open for writing.\n"; | |
exit; | |
} | |
$src_file = fopen ($f, "r"); | |
if (!$src_file) { | |
echo "<p>Error: Unable to remote open for reading.\n"; | |
exit; | |
} | |
// Write the data here. | |
while (!feof ($src_file)) { | |
$line = fgets ($src_file, 1024); | |
fwrite ($dest_file, $line); | |
} | |
fclose ($dest_file); | |
fclose ($src_file); | |
echo "File succesfully downloaded<br/>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment