Reputation: 119
Can someone tell me how to get the data from post request body(form-data)?
This is how I am calling the API using Postman:
I am printing the input using below code:
$data = file_get_contents('php://input');
echo $data;
This is the output that I get:
------WebKitFormBoundarycHQ9xxbmOdQAcZNF
Content-Disposition: form-data; name="testFile"; filename="abc.csv"
Content-Type: application/vnd.ms-excel
Name,Value
test,QA
contact,789789
------WebKitFormBoundarycHQ9xxbmOdQAcZNF
Content-Disposition: form-data; name="testData"
['aa','bbbb']
------WebKitFormBoundarycHQ9xxbmOdQAcZNF
Content-Disposition: form-data; name="testBool"
true
------WebKitFormBoundarycHQ9xxbmOdQAcZNF--
How can extract the csv data, testData array, and testBool value from the form-data?
Upvotes: 0
Views: 2004