Created
March 22, 2017 07:50
-
-
Save artygrand/2fd92d2919d1274d5e0f6921eb64eaa7 to your computer and use it in GitHub Desktop.
Curl file loader
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 | |
set_time_limit(0); | |
$file = dirname(__FILE__) . '/file.tgz'; | |
$url = 'http://site/file.tgz'; | |
$file_offset=filesize($file); | |
$file_offset=$file_offset-1024*4; | |
$fp = fopen($file,'ab+'); | |
rewind($fp); | |
ftruncate($fp, $file_offset); | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RESUME_FROM, $file_offset); | |
curl_setopt($ch, CURLOPT_FILE, $fp); | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
/* | |
$fp = fopen($file, 'w+'); | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_FILE, $fp); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
*/ | |
echo 'loaded!'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment