Re: retrieve POST body?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tijnema ! wrote:
On 4/19/07, Myron Turner <turnermm02@xxxxxxx> wrote:
André Medeiros wrote:
> php://stdin perhaps?
>
> On 4/18/07, Justin Frim <jfrim@xxxxxxxxxxx> wrote:
>> André Medeiros wrote:
>>
>> > Reading from php://input on a webserver will retrieve the Body of the
>> > HTTP Request.
>>
>> Not for me it doesn't.
>> That only seems to work when the form is submitted as
>> application/x-www-form-urlencoded.  When the form is submitted as
>> multipart/form-data, php://input is blank.
>
You probably could use this small Perl script via exec:

#!/usr/bin/perl
if ($ENV{'REQUEST_METHOD'} eq "POST") {
   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}

print $buffer;

If you call this script via exec, it can't return the POST data send
to the PHP script right?

You're right. It doesn't carry across from Perl to PHP. As penance, I worked out how to do it using PHP:

<form action = "post_data.php" method="post">
<input type= "hidden" value = "abcdefg" name="post_test">
<input type = "submit"  name="submit" value="submit_this">
</form>

<?php
if(isset($_POST['submit'])) {


$putdata = fopen("php://input", "r");

/* Read the data and write it to stdout */
while ($data = fread($putdata, 1024))
 echo $data, "\n";

/* Close the streams */
fclose($fp);
fclose($putdata);

}
?>

btw, we are here on a PHP list, not PERL :)

Does this mean you wouldn't use exec or system to run anything but PHP scripts? Or just that you wouldn't talk about it here, under penalty of exclusion from PHP heaven? :)


--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux