我正在尝试使用 curl 将数据发送到远程页面
这是表单部分的来源:
<form action="" method="POST" enctype="multipart/form-data">
<table align="center" cellspacing="0" cellpadding="5">
<tr><td>Type: </td><td width=100%><select name="service">
<option value="3">blah blah</option>
<option value="4">blah blah </option>
<option value="10"blll</option>
<option value="11">bbbb</option>
</select></td>
<tr><td>Link: </td><td><textarea name="url" cols="120" rows="10"></textarea></td>
<tr><td>Quantity: </td><td><input type="text" name="count" placeholder=""></td>
<tr><td>Initial Count (not required): </td><td><input type="text" name="incount" placeholder="" value="-1"></td>
<tr><td colspan=2><input type="submit" name="submit" value="Submit"></td>
</table>
</form>
我正在使用这个卷曲代码:
$header = array("Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryg5cfCMAC4o4JEbaz");
$postfields = array();
$postfields[] = array("service", "10");
$postfields[] = array("url", "something");
$postfields[] = array("count", "1000");
$postfields[] = array("incount", "-1");
$postfields[] = array("submit", "Submit");
$proxy = '155.241.126.244:60099';
$proxyauth = '123:123';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://xxxx/xx/news.php");
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, "http://xxxx/xx/news.php");
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_exec ($ch);
curl_close($ch);
这似乎不起作用(这边没有错误,另一端没有收到数据),我在这里做错了什么?是标题吗?我认为 enctype="multipart/form-data" 是我的敌人..