0

It's basically a webservice for android developers. Below is the function made by me to get the input request from url.

function  readInputStream() {
        $return_array = array();
        $body = @file_get_contents('php://input');
        if(get_magic_quotes_gpc()) 
        {
            $body = stripslashes($body);
        }
        // check if body is compressed or not
        if (strlen($body) < 18 || strcmp(substr($body,0,2),"\x1f\x8b")) 
        {
            $body = $body;
        } 
        else 
        {
            $tbody = $this->gzdecode($body);
            $body = $tbody;
        }
        if(!empty($body)) 
        {
            $return_array = json_decode($body, true);
        }
        
        return $return_array;
        
}

Now I want to combine post and file request.

I know that php://input will get all post requests. But i want to include file request as well in this function.

$body = @file_get_contents('php://input'); 

So, how can I merge post and file requests in $body variable in the above function?

I tried to like this it's not working,

$body = @file_get_contents('php://input'); 
$body .= @file_get_contents('php://fd'); 

Also tried like,

$body = @file_get_contents('php://input'); 
$body .= $_FILES;
Ahmad Adibzad
  • 501
  • 2
  • 6
  • 14
Bhavin
  • 2,070
  • 6
  • 35
  • 54
  • Why not use a standard form post? – Jay Blanchard Jul 17 '17 at 12:25
  • @JayBlanchard. thank you for your reply. Because there are so many webservices are using this function and I'm changing webservices current webservice is also using this function but at that time there isn't any file upload but now due to requirement I have to add file upload in current webservice. – Bhavin Jul 17 '17 at 12:27

0 Answers0