OneMoreTime
OneMoreTime

Reputation: 13

How to access data Using the php://input stream in Codeigniter

I have a problem in my CI framework website. My AJAX (client) calls a ReSTful API (server) with PUT method.

In Server. I use :

putfp = fopen('php://input', 'r');
$putdata = '';
while($data = fread($putfp, 1024))
  $putdata .= $data;
fclose($putfp);
parse_str($putdata, $output);
echo $output['name'];

And I had a value of $name from client. e.t.c for other variable. But in document guide of this Framework, they said like this: https://www.codeigniter.com/user_guide/libraries/input.html#using-the-php-input-stream

My question is:

How to use $this->input->raw_input_stream;

Because I want to do like document guide said. I tried and result was all error. I don't know where I should put $this->input->raw_input_stream; into and how to get the data with that.

Anyone help me with example?

Upvotes: 0

Views: 2508

Answers (1)

BEingprabhU
BEingprabhU

Reputation: 1686

You can try PHP built in, file_get_contents('php://input') method.

OR

Refer this URL https://www.codeigniter.com/user_guide/libraries/input.html#using-the-php-input-stream

Hope this can help you.

Upvotes: 1

Related Questions