我有一个AJAX请求,发出以下信息(通过POST)。一切都很好,除了在请求的PHP文件中$_POST
超全局为空。
我正在提供Firebug的标题和帖子标签:
标题标签:
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
帖子标签:
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 passwords 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--
很抱歉很长的帖子,谢谢!
更新
正如polarblau建议我试过`echo file_get_contents('php:// input');'输出以下内容:
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--
这非常好,但我仍然不知道为什么我的$_POST
没有填充。我甚至试图强迫$_SERVER['CONTENT_TYPE'] = 'multipart/form-data';
但没有结果。
答案 0 :(得分:1)
This guy here似乎为这种情况提出了一个很好的调试方法:
$data = file_get_contents('php://input');
这应该会给你'原始传入消息'。如果这显示,您实际上有传入的数据,他建议强制使用内容类型,以防在发出请求时被搞乱:
if(empty($_SERVER['CONTENT_TYPE'])){
$type = "application/x-www-form-urlencoded";
$_SERVER['CONTENT_TYPE'] = $type;
}