View Single Post
Old 05-09-2008, 11:20 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 651
Thanks: 2
Salathe is on a distinguished road
Default

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($chCURLOPT_FILE$fh);

// Execute the request
curl_exec($ch);

// Close handlers
curl_close($ch);
fclose($fh);

// Display that sexy logo!
echo '<img src="misc.jpg" />';
__________________
Salathe is offline  
Reply With Quote