Created
October 17, 2016 12:24
-
-
Save hsleonis/279f24ce3d5076cba1b31235bb2fea66 to your computer and use it in GitHub Desktop.
Download file to server with PHP
This file contains hidden or 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 | |
| // file_put_contents("MoviePy.zip", fopen("https://github.com/Zulko/moviepy/archive/master.zip", 'r')); | |
| function downloadFile($url, $path) | |
| { | |
| $newfname = $path; | |
| $file = fopen ($url, 'rb'); | |
| $i = 0; | |
| if ($file) { | |
| $newf = fopen ($newfname, 'wb'); | |
| if ($newf) { | |
| while(!feof($file)) { | |
| fwrite($newf, fread($file, 1024 * 8), 1024 * 8); | |
| $i++; | |
| } | |
| } | |
| } | |
| if (isset($file) && gettype($file)=='resource') { | |
| fclose($file); | |
| } | |
| if (isset($newf) && gettype($newf)=='resource') { | |
| fclose($newf); | |
| } | |
| return $i; | |
| } | |
| downloadFile('https://lgithub.com/Zulko/moviepy/archive/master.zip', 'MoviePy2.zip'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment