Ahmad Sami
Ahmad Sami

Reputation: 327

post files from postman to PHP

I'm trying to send some data from postman to server but PHP always return null, PHP only gets the data when I send it using raw body.

postman form-data

PHP Code:

<?php

  require_once("_config.php");

  if($_SERVER['PHP_AUTH_USER'] == AUTH_USER && $_SERVER['PHP_AUTH_PW'] == AUTH_PW){

    $data = file_get_contents("php://input");
    echo $data;
  }

?>

Upvotes: 2

Views: 3613

Answers (1)

Ahmad Sami
Ahmad Sami

Reputation: 327

Okay guys, I solved it by removing one of postman headers. I removed Content-Type.

postman Content-Type header

Upvotes: 4

Related Questions