So here's the situation: I need to write a PHP script which accepts form submissions using all methods (GET and POST) and all content types (application/x-www-form-url-encoded and multipart/form-data). And for POST method, it has to be able to get the exact bit-for-bit accurate contents of the POST body.
Now here's the problem: I'm stuck with POST multipart/form-data. The $GLOBALS['HTTP_RAW_POST_DATA'] only works with application/x-www-form-url-encoded. It does not work with multipart/form-data. Neither does $HTTP_RAW_POST_DATA. Same goes for using fopen('php://input', 'rb'). Attempting to read from fopen('php://stdin', 'rb') doesn't return any data at all, regardless of the request method or content-type. The PHP docs have a few clues suggesting it is possible to read from stdin without using the stream fuctions (php://), but I have not found any information on how to do this.
And here's another related dilemma: How does one create a form with a server-side image map and a file upload, and submit it to a PHP script where the script successfully accepts the file and knows the exact names and values of all the form fields? Think about it... you need to use multipart/form-data to submit forms with file uploads. And form-based server-side image maps append a ".x" and ".y" suffix to the form field name to create two more fields containing the X and Y pixel coordinates respectively of where the user clicked on the image. But PHP converts all spaces and periods/decimals/full-stops in form field names to underscores/underlines for the $_GET[], $_POST[], $_COOKIE[], and $_REQUEST[] arrays. So those ".x" and ".y" suffixes become "_x" and "_y". Further, if any form field names contain opening and closing square brackets, PHP turns them into a subarray data type! And if a lone opening square bracket is found, it too becomes an underline/underscore. Without any alternative ways of obtaining the POST data for multipart/form-data submissions, it's impossible for a PHP script to get the true names of the form fields!
There's got to be a solution to this. Any ideas?