遇到个超级郁闷的事情,用C写的socket程序 模拟 向 multipart/form-data 表单post数据时 对方页面接不到任何数据,但用php页面提交时却能收到,我用抓包程序抓网络包,看了下两个数据包,没多大差别啊,为何C的收不到?C程序的数据包
POST /h.php HTTP/1.1
Host: localhost
Connection: Keep-Alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn, en-us;q=0.7, en;q=0.3
Accept-Charset: gb2312, utf-8;q=0.7, *;q=0.7
Content-Type: multipart/form-data; boundary=-----------------------------3031142221098
Content-Length: 354-----------------------------3031142221098
Content-Disposition: form-data; name="user"allenloveJohn
-----------------------------3031142221098
Content-Disposition: form-data; name="pwd"super137
-----------------------------3031142221098
Content-Disposition: form-data; name="content"qqqqqq
-----------------------------3031142221098--php网页页面的能收到
POST /h.php HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://localhost/upload_from.php
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)
Content-Type: multipart/form-data; boundary=---------------------------7db3b230805f4
Accept-Encoding: gzip, deflate
Host: localhost
Content-Length: 354
Connection: Keep-Alive
Cache-Control: no-cache-----------------------------7db3b230805f4
Content-Disposition: form-data; name="user"allenloveJohn
-----------------------------7db3b230805f4
Content-Disposition: form-data; name="pwd"super137
-----------------------------7db3b230805f4
Content-Disposition: form-data; name="content"qqqqqq
-----------------------------7db3b230805f4--
POST /h.php HTTP/1.1
Host: localhost
Connection: Keep-Alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn, en-us;q=0.7, en;q=0.3
Accept-Charset: gb2312, utf-8;q=0.7, *;q=0.7
Content-Type: multipart/form-data; boundary=-----------------------------3031142221098
Content-Length: 354-----------------------------3031142221098
Content-Disposition: form-data; name="user"allenloveJohn
-----------------------------3031142221098
Content-Disposition: form-data; name="pwd"super137
-----------------------------3031142221098
Content-Disposition: form-data; name="content"qqqqqq
-----------------------------3031142221098--php网页页面的能收到
POST /h.php HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Referer: http://localhost/upload_from.php
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)
Content-Type: multipart/form-data; boundary=---------------------------7db3b230805f4
Accept-Encoding: gzip, deflate
Host: localhost
Content-Length: 354
Connection: Keep-Alive
Cache-Control: no-cache-----------------------------7db3b230805f4
Content-Disposition: form-data; name="user"allenloveJohn
-----------------------------7db3b230805f4
Content-Disposition: form-data; name="pwd"super137
-----------------------------7db3b230805f4
Content-Disposition: form-data; name="content"qqqqqq
-----------------------------7db3b230805f4--
"php://input"只能获取非 multipart/form-data 的数据,真是痛苦
参考一下
http://us.php.net/manual/en/wrappers.php.php看看对你有没有帮助