Add download file with redirection example

This commit is contained in:
Zach Borboa
2016-09-12 00:33:07 -07:00
parent 31cd3aa889
commit dfc36bb38f
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
<?php
require __DIR__ . '/vendor/autoload.php';
use \Curl\Curl;
$start_url = 'https://php.net/images/logos/php-med-trans.png';
$final_url = 'https://secure.php.net/images/logos/php-med-trans.png';
$curl = new Curl();
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
$curl->download($start_url, '/tmp/php-med-trans.png');
assert($final_url === $curl->effectiveUrl);
+1 -1
View File
@@ -12,4 +12,4 @@ $curl->progress(function ($client, $download_size, $downloaded, $upload_size, $u
$percent = floor($downloaded * 100 / $download_size);
echo ' ' . $percent . '%' . "\r";
});
$curl->download('https://php.net/distributions/manual/php_manual_en.html.gz', '/tmp/php_manual_en.html.gz');
$curl->download('https://secure.php.net/distributions/manual/php_manual_en.html.gz', '/tmp/php_manual_en.html.gz');