mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-17 21:05:20 +00:00
25 lines
656 B
PHP
25 lines
656 B
PHP
<?php
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
// Note: The server needs to send a content-length header for progress to work.
|
|
|
|
use Curl\Curl;
|
|
|
|
$curl = new Curl();
|
|
$curl->progress(function ($client, $download_size, $downloaded, $upload_size, $uploaded) {
|
|
if ($download_size === 0) {
|
|
return;
|
|
}
|
|
|
|
$percent = floor($downloaded * 100 / $download_size);
|
|
echo ' ' . $percent . '%' . "\r";
|
|
});
|
|
$curl->download('https://www.php.net/distributions/manual/php_manual_en.html.gz', '/tmp/php_manual_en.html.gz');
|
|
|
|
if ($curl->error) {
|
|
echo 'Download error: ' . $curl->errorMessage . "\n";
|
|
} else {
|
|
echo 'Download complete' . "\n";
|
|
}
|