Command line:
Single file:
curl -o myName.zip http://huypv.net/share/docs/server.zip
Multiple files:
curl -o pages#1.html http://example.com/pages.php?pageNo=[1-12]
PHP code
For small file:
<?php
$url = 'http://www.example.com/a-small-file.zip';
$path = '/path/to/a-large-file.zip';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
file_put_contents($path, $data);
For large file:
<?php
$url = 'http://www.example.com/a-large-file.zip';
$path = '/path/to/a-large-file.zip';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
Title:
cURL download file
Description:
Command line: Single file: curl -o myName.zip http://huypv.net/share/docs/server.zip Multiple files: curl -o pages#1.html http://exampl...
...
Rating:
4