note 83948 deleted from function.curl-setopt by danbrown

From: Date: Thu, 05 May 2011 14:54:15 +0000
Subject: note 83948 deleted from function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179455@lists.php.net to get a copy of this message
Note Submitter: heron at xnapid dot com ---- Someone posted this under tmpfile (http://us3.php.net/manual/en/function.tmpfile.php#69419), and I thought it was particularly useful: [The PHP function tmpfile()] is really useful for libcurl's CURLOPT_PUT feature if what you're trying to PUT is a string. For example: <?php /* Create a cURL handle. */ $ch = curl_init(); /* Prepare the data for HTTP PUT. */ $putString = "Hello, world!"; $putData = tmpfile(); fwrite($putData, $putString); fseek($putData, 0); /* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, "http://www.example.com"); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString)); /* ... (other curl options) ... */ /* Execute the PUT and clean up */ $result = curl_exec($ch); fclose($putData); curl_close($ch); ?>

« previous php.notes (#179455) next »