{"id":4768,"date":"2025-03-13T12:12:04","date_gmt":"2025-03-13T12:12:04","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4768"},"modified":"2026-02-17T14:57:19","modified_gmt":"2026-02-17T14:57:19","slug":"getting-posted-data","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/forms\/getting-posted-data","title":{"rendered":"Getting posted data"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Get POST and FILES into an array then json<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  $DebugCapture = array();\n  $DebugCapture&#91;'POST'] = $_POST;\n  $DebugCapture&#91;'FILES'] = $_FILES;\n  $DebugCapture = json_encode($DebugCapture, (JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Write json POST to a file in API handler so you can view it<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/Retrieve the raw POST data\n  $JsonData = file_get_contents('php:\/\/input');\n\n  \/\/Write to a debug file\n  \/\/file_put_contents(\"debugtemp\/myapidebugfile.txt\", PHP_EOL . PHP_EOL . $JsonData, FILE_APPEND | LOCK_EX);\t\t\t\/\/(Create or append if exists))\n\n  $DecodedJson = json_decode($JsonData, True);\n  if (!is_null($DecodedJson))\n  {\n    \/\/Write to a debug file\n    file_put_contents(\"debugtemp\/myapidebugfile_json.txt\", PHP_EOL . PHP_EOL . print_r($DecodedJson, true), FILE_APPEND | LOCK_EX);\t\t\t\/\/(Create or append if exists))\n\n  }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Get POST and FILES into an array then json Write json POST to a file in API handler so you can view it<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[358,42],"tags":[],"class_list":["post-4768","post","type-post","status-publish","format-standard","hentry","category-apis","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4768"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4768\/revisions"}],"predecessor-version":[{"id":5290,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4768\/revisions\/5290"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}