Last active
January 7, 2020 15:07
-
-
Save smarteist/03bd150d184f13d4383733e9eea14edd to your computer and use it in GitHub Desktop.
download using 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 to download. | |
| $url = 'http://195.248.240.40/bs/q7HOz9I1yd3qoyoLjsQu/user.admin.hilet.2019-12-27_11-00-18_GMT.tar.gz'; | |
| // Open file | |
| $fp = fopen($url, 'r'); | |
| file_put_contents(basename($url), $fp); | |
| // Close file | |
| fclose($fp); | |
| ?> |
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 | |
| // resumable downloader | |
| function download_file($url) | |
| { | |
| $fileName = basename($url); | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| if (file_exists($fileName)) { | |
| $from = filesize($fileName); | |
| curl_setopt($ch, CURLOPT_RANGE, $from . "-"); | |
| } | |
| $fp = fopen($fileName, "a"); | |
| if (!$fp) { | |
| exit; | |
| } | |
| curl_setopt($ch, CURLOPT_FILE, $fp); | |
| curl_exec($ch); | |
| curl_close($ch); | |
| fclose($fp); | |
| echo 'download finished'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment