php://input

From: Date: Sun, 15 Jan 2012 05:18:32 +0000
Subject: php://input
Groups: php.general 
Request: Send a blank email to php-general+get-316297@lists.php.net to get a copy of this message
Hi, I am trying to read variables from input method. I am using this tuorial: http://www.lornajane.net/posts/2008/Accessing-Incoming-PUT-Data-from-PHP. Here is my code: <?php if($_SERVER['REQUEST_METHOD'] == 'GET') { echo "this is a get request\n"; echo $_GET['fruit']." is the fruit\n"; echo "I want ".$_GET['quantity']." of them\n\n"; } elseif($_SERVER['REQUEST_METHOD'] == 'PUT') { echo "this is a put request\n"; parse_str(file_get_contents("php://input"),$post_vars); echo $post_vars['fruit']." is the fruit\n"; echo "I want ".$post_vars['quantity']." of them\n\n"; } ?> I am using the firefox extension "poster" to run this example. GET works fine but when using PUT, file_get_contents("php://input") returns an empty string. I found a bug related to this: https://bugs.php.net/bug.php?id=51592 I am using xampp on win7 ( + Apache 2.2.17 + MySQL 5.5.8 (Community Server) + PHP 5.3.5 (VC6 X86 32bit) + PEAR)

« previous php.general (#316297) next »