05-09-2008, 11:20 PM
|
#2 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 651
Thanks: 2
|
Thanks for posting up your code snippet! When simply using cURL to grab a file and save it to the local file system, there is the option to tell cURL to do that rather than making us do it with fwrite; that option is CURLOPT_FILE.
PHP Code:
<?php
// Initialize handlers
$ch = curl_init('http://www.talkphp.com/images/talkphp/talkphp_logo.jpg');
$fh = fopen('misc.jpg', 'w+');
// Set cURL to save to a file (normally stdout)
curl_setopt($ch, CURLOPT_FILE, $fh);
// Execute the request
curl_exec($ch);
// Close handlers
curl_close($ch);
fclose($fh);
// Display that sexy logo!
echo '<img src="misc.jpg" />';
__________________
|
|
|
|