传递带cURL的$POST值你怎么通过$_POST值到页的cURL?
3 回答
森栏
TA贡献1810条经验 获得超5个赞
$data = array('name' => 'Ross', 'php_master' => true);// You can POST a file by prefixing with an @ (for <input type="file">
fields)$data['file'] = '@/home/user/world.jpg';$handle = curl_init($url);curl_setopt($handle, CURLOPT_POST, true);c
url_setopt($handle, CURLOPT_POSTFIELDS, $data);curl_exec($handle);curl_close($handle)CURLOPT_POSTCURLOPT_POSTFIELDSPOST <form>
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$data作为 array()*数据将作为 multipart/form-data它并不总是被服务器所接受。 $data = array('name' => 'Ross', 'php_master' => true);curl_setopt($handle, CURLOPT_POSTFIELDS, $data);$data作为url编码的字符串:数据将作为 application/x-www-form-urlencoded,它是提交的html表单数据的默认编码。 $data = array('name' => 'Ross', 'php_master' => true);curl_setopt($handle, CURLOPT_POSTFIELDS, http_build_query($data));
四季花海
TA贡献1811条经验 获得超5个赞
$xml = '<?xml version="1.0"?><stuff><child>foo</child><child>bar</child>
</stuff>';$httpRequest = curl_init();curl_setopt($httpRequest, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($httpRequest, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($httpRequest, CURLOPT_POST, 1);curl_setopt($httpRequest, CURLOPT_HEADER, 1);
curl_setopt($httpRequest, CURLOPT_URL, $url);curl_setopt($httpRequest, CURLOPT_POSTFIELDS, $xml);
$returnHeader = curl_exec($httpRequest);curl_close($httpRequest);CURLOPT_RETURNTRANSFERCURLOPT_HEADER.
- 3 回答
- 0 关注
- 469 浏览
添加回答
举报
0/150
提交
取消
