note 92522 added to function.curl-setopt

From: Date: Tue, 28 Jul 2009 10:05:03 +0000
Subject: note 92522 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-158812@lists.php.net to get a copy of this message
When you are using CURLOPT_FILE to download directly into a file you must close the file handler after the curl_close() otherwise the file will be incomplete and you will not be able to use it until the end of the execution of the php process. <?php $fh = fopen('/tmp/foo', 'w'); $ch = curl_init('http://foo.bar/foo'); curl_setopt($ch, CURLOPT_FILE, $fh); curl_exec($ch); curl_close($ch); # at this point your file is not complete and corrupted fclose($fh); # now you can use your file; read_file('/tmp/foo'); ?> ---- Server IP: 89.31.146.176 Probable Submitter: 80.13.22.90 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/92522 Del: integrated -- https://master.php.net/note/delete/92522/integrated Del: useless -- https://master.php.net/note/delete/92522/useless Del: bad code -- https://master.php.net/note/delete/92522/bad+code Del: spam -- https://master.php.net/note/delete/92522/spam Del: non-english -- https://master.php.net/note/delete/92522/non-english Del: in docs -- https://master.php.net/note/delete/92522/in+docs Del: other reasons-- https://master.php.net/note/delete/92522 Reject -- https://master.php.net/note/reject/92522 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158812) next »