note 92441 deleted from function.copy by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Jul 2009 12:46:31 +0000 |
| Subject: | note 92441 deleted from function.copy by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158684@lists.php.net to get a copy of this message | ||
Note Submitter: srabot at steek dot com
Reason: useless
----
When you are using CURLOPT_FILE to download directly into a file, don't forget to close the
resource given to curl_setopt otherwise the file will be corrupted until the end of the
script's execution :
<?php
$ch = curl_init('http://foo.bar/foo.txt');
$fh = fopen('/tmp/foo.txt', 'w+);
curl_setopt(CURLOPT_FILE, $fh);
curl_exec($fh);
curl_close(ch);
fclose($fh);
?>