Skip to content

Commit dfc36bb

Browse files
committed
Add download file with redirection example
1 parent 31cd3aa commit dfc36bb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
require __DIR__ . '/vendor/autoload.php';
3+
4+
use \Curl\Curl;
5+
6+
$start_url = 'https://php.net/images/logos/php-med-trans.png';
7+
$final_url = 'https://secure.php.net/images/logos/php-med-trans.png';
8+
9+
$curl = new Curl();
10+
$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
11+
$curl->download($start_url, '/tmp/php-med-trans.png');
12+
13+
assert($final_url === $curl->effectiveUrl);

examples/progress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
$percent = floor($downloaded * 100 / $download_size);
1313
echo ' ' . $percent . '%' . "\r";
1414
});
15-
$curl->download('https://php.net/distributions/manual/php_manual_en.html.gz', '/tmp/php_manual_en.html.gz');
15+
$curl->download('https://secure.php.net/distributions/manual/php_manual_en.html.gz', '/tmp/php_manual_en.html.gz');

0 commit comments

Comments
 (0)