note 69419 modified in function.tmpfile by danbrown

From: Date: Sun, 17 May 2009 17:20:58 +0000
Subject: note 69419 modified in function.tmpfile by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154969@lists.php.net to get a copy of this message
By the way, this function 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); ?> --was-- By the way, this function is really useful for libcurl's CURLOPT_PUT feature if what you're trying to PUT is a string. For example: /* 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); http://php.net/manual/en/function.tmpfile.php

« previous php.notes (#154969) next »