mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-31 04:34:27 +00:00
Add download file with redirection example
This commit is contained in:
@@ -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);
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user