I have an AJAX request that sends out the following information (via POST). All is well except in the requested PHP file the $_POST
superglobal is empty.
I am providing Firebug's Headers and Post tabs:
Headers tab:
Response Headers view source Date Sun, 23 Jan 2011 08:41:03 GMT Server Apache X-Powered-By PHP/5.2.13 Expires Thu, 19 Nov 1981 08:52:00 GMT Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma no-cache Content-Length 127 Connection close Content-Type text/html Request Headers view source Host xx User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive Referer http://xx/florin2/cautare Content-Length 2325 Content-Type text/plain; charset=UTF-8 Cookie PHPSESSID=8367d170xx
Post tab:
Parts multipart/form-data titluPublic PDG Archivarius nr_versiune nume_developer Astonsoft site_developer site_produs pret_vechi pret_actual 9.95 link_pret /nph-softsell.cgi?item=2304-3&affiliate=441937 size 20.00 zilePromo 0 startPromo 0000-00-00 date_added 2009-02-01 dataupdate 0000-00-00 rating 0 nr_download 191 id_pad 0 featured 0 license Shareware os Windows id_subcat_f 102 subtitlu An advanced zipping utility wich allows to recover .zip passwords and do anti-virus scanni... description An advanced zipping utility wich allows to recover .zip passwords and do anti-virus scanning. features review pro contra requirements limitations Source Content-Type: multipart/form-data; boundary=gRNHZ7wzOS --gRNHZ7wzOS Content-Disposition: form-data; name="titluPublic" PDG Archivarius --gRNHZ7wzOS Content-Disposition: form-data; name="nr_versiune" --gRNHZ7wzOS Content-Disposition: form-data; name="nume_developer" Astonsoft --gRNHZ7wzOS Content-Disposition: form-data; name="site_developer" --gRNHZ7wzOS Content-Disposition: form-data; name="site_produs" --gRNHZ7wzOS Content-Disposition: form-data; name="pret_vechi" --gRNHZ7wzOS Content-Disposition: form-data; name="pret_actual" 9.95 --gRNHZ7wzOS Content-Disposition: form-data; name="link_pret" /nph-softsell.cgi?item=2304-3&affiliate=441937 --gRNHZ7wzOS Content-Disposition: form-data; name="size" 20.00 --gRNHZ7wzOS Content-Disposition: form-data; name="zilePromo" 0 --gRNHZ7wzOS Content-Disposition: form-data; name="startPromo" 0000-00-00 --gRNHZ7wzOS Content-Disposition: form-data; name="date_added" 2009-02-01 --gRNHZ7wzOS Content-Disposition: form-data; name="dataupdate" 0000-00-00 --gRNHZ7wzOS Content-Disposition: form-data; name="rating" 0 --gRNHZ7wzOS Content-Disposition: form-data; name="nr_download" 191 --gRNHZ7wzOS Content-Disposition: form-data; name="id_pad" 0 --gRNHZ7wzOS Content-Disposition: form-data; name="featured" 0 --gRNHZ7wzOS Content-Disposition: form-data; name="license" Shareware --gRNHZ7wzOS Content-Disposition: form-data; name="os" Windows --gRNHZ7wzOS Content-Disposition: form-data; name="id_subcat_f" 102 --gRNHZ7wzOS Content-Disposition: form-data; name="subtitlu" An advanced zipping utility wich allows to recover .zip passwords and do anti-virus scanni... --gRNHZ7wzOS Content-Disposition: form-data; name="description" An advanced zipping utility wich allows to recover .zip pas开发者_JAVA百科swords and do anti-virus scanning. --gRNHZ7wzOS Content-Disposition: form-data; name="features" --gRNHZ7wzOS Content-Disposition: form-data; name="review" --gRNHZ7wzOS Content-Disposition: form-data; name="pro" --gRNHZ7wzOS Content-Disposition: form-data; name="contra" --gRNHZ7wzOS Content-Disposition: form-data; name="requirements" --gRNHZ7wzOS Content-Disposition: form-data; name="limitations" --gRNHZ7wzOS--
Sorry for the very long post and thanks!
UPDATE
as polarblau suggested I tried `echo file_get_contents('php://input');' which outputs the following:
Content-Type: multipart/form-data; boundary=zMgU0RnQIk --zMgU0RnQIk Content-Disposition: form-data; name="titluPublic" Feldenkrais Pelvic Clock Variations --zMgU0RnQIk Content-Disposition: form-data; name="nr_versiune" --zMgU0RnQIk Content-Disposition: form-data; name="nume_developer" Integrated-Learning --zMgU0RnQIk Content-Disposition: form-data; name="site_developer" --zMgU0RnQIk Content-Disposition: form-data; name="site_produs" --zMgU0RnQIk Content-Disposition: form-data; name="pret_vechi" --zMgU0RnQIk Content-Disposition: form-data; name="pret_actual" 7 --zMgU0RnQIk Content-Disposition: form-data; name="link_pret" /nph-softsell.cgi?item=14294-5&affiliate=441937 --zMgU0RnQIk Content-Disposition: form-data; name="size" 20.00 --zMgU0RnQIk Content-Disposition: form-data; name="zilePromo" 0 --zMgU0RnQIk Content-Disposition: form-data; name="startPromo" 0000-00-00 --zMgU0RnQIk Content-Disposition: form-data; name="date_added" 2009-02-01 --zMgU0RnQIk Content-Disposition: form-data; name="dataupdate" 0000-00-00 --zMgU0RnQIk Content-Disposition: form-data; name="rating" 0 --zMgU0RnQIk Content-Disposition: form-data; name="nr_download" 261 --zMgU0RnQIk Content-Disposition: form-data; name="id_pad" 0 --zMgU0RnQIk Content-Disposition: form-data; name="featured" 0 --zMgU0RnQIk Content-Disposition: form-data; name="license" Shareware --zMgU0RnQIk Content-Disposition: form-data; name="os" Windows --zMgU0RnQIk Content-Disposition: form-data; name="id_subcat_f" 7 --zMgU0RnQIk Content-Disposition: form-data; name="subtitlu" Feldenkrais Lesson Pelvic Clock Variations This Feldenkrais lesson takes the theme of the ... --zMgU0RnQIk Content-Disposition: form-data; name="description" Feldenkrais Lesson Pelvic Clock Variations This Feldenkrais lesson takes the theme of the Pelvic Clock in other directions. Its value lies in the slightly different demands it places on your nervous system. This is how you can develop with variation of a Feldenkrais Lesson. It is very useful to do this. It helps in developing the subtle and intricate qualities of awareness that a Feldenkrais lesson and Feldenkrais Practitioners are renowned for. Develop a greater mobility with your pelvis. --zMgU0RnQIk Content-Disposition: form-data; name="features" --zMgU0RnQIk Content-Disposition: form-data; name="review" --zMgU0RnQIk Content-Disposition: form-data; name="pro" --zMgU0RnQIk Content-Disposition: form-data; name="contra" --zMgU0RnQIk Content-Disposition: form-data; name="requirements" --zMgU0RnQIk Content-Disposition: form-data; name="limitations" --zMgU0RnQIk--
This is very good, but I still don't know why my $_POST
is not populated. I even tried forcing $_SERVER['CONTENT_TYPE'] = 'multipart/form-data';
but with no result.
This guy here at bradino.com seems to suggest a nice debugging method for this case:
$data = file_get_contents('php://input');
This should give you the 'raw incoming message'. If this shows, that you in fact have incoming data, he suggests to force a content type in case that has been messed–up when making the request:
if(empty($_SERVER['CONTENT_TYPE'])){
$type = "application/x-www-form-urlencoded";
$_SERVER['CONTENT_TYPE'] = $type;
}
精彩评论