Created
February 14, 2014 14:45
-
-
Save simonbernard/9002227 to your computer and use it in GitHub Desktop.
It took me some time so I would like to share with you: How-to download a file with PHP's cURL and afterwards continue with other cURL requests which return their output as usual.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$fh = fopen('/your/target/file', 'w'); | |
curl_setopt($ch, CURLOPT_FILE, $fh); | |
curl_setopt($ch, CURLOPT_HTTPGET, true); | |
curl_setopt($ch, CURLOPT_URL, 'http://your/download/url'); | |
curl_exec($ch); | |
// revert it | |
curl_setopt($this->ch, CURLOPT_FILE, STDOUT); | |
fclose($fh); // don't forget to close the handle | |
// important if you want to get the output of the next requests | |
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment