Search code examples
phppostfile-get-contentspostman

can't retrive raw post data using file_get_contents('php://input')


this is my code. and i am posting my data using post method.

$post_body = file_get_contents('php://input');
if(getenv('REQUEST_METHOD') == 'POST'){
    print_r( array( "3","3d"));
}
print_r($post_body);

i am using chrome's postman to test this code,but it don't print post data, see output image.

output image

what i am doing wrong???

EDIT

To show how i solve my problem i am adding this image.

To show


Solution

  • According to PHP documentation

    php://input is not available with enctype="multipart/form-data".

    Postman supports different types of Content-Type including multipart/form-data which seems to be default.

    So make sure you don't use multipart/form-data(in the Body tab).