1
我写了一个小应用程序,前一段时间使用curl并正在工作。今天我试图运行它,它不工作。PHP的curl不发布数据到服务器
我使用curl将数据发布到位于外部服务器上的另一个页面。获取正在工作,但不是帖子。
更新1:
我已经缩小误差降低到具有所谓的“SOME_KEY”的条目,并具有值“‘@C:/wamp/www/name.pdf’”的职位数组会导致这个问题。
怎么样@符号导致问题!!!我想一个文件uplaod服务器
解决
检查下面的答案。
原始入口
我现在的卷曲选项
$curl_options = array(
CURLOPT_RETURNTRANSFER => true, // Return web page
CURLOPT_HEADER => false, // Don't return headers
CURLOPT_FOLLOWLOCATION => false, // Follow redirects
CURLOPT_ENCODING => "", // Handle all encodings
CURLOPT_AUTOREFERER => false, // Set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // Timeout on connect
CURLOPT_TIMEOUT => 120, // Timeout on response
CURLOPT_MAXREDIRS => 0, // Stop after 10 redirects
CURLOPT_USERAGENT => "regify connector", // Who am I? FIREFOX, IE, OPERA, CHROME, SPIDER, SEARCH BOT...etc.
);
的功能帖中的数据:
function makePostRequest($url, $fields ){
//Create the options
//global $curl_options;
$curl_options[CURLOPT_URL ] = $url;
$curl_options[CURLOPT_POST ] = count($fields);
$curl_options[CURLOPT_POSTFIELDS] = $fields;
$ch = curl_init();
curl_setopt_array($ch, $curl_options);
$content = curl_exec ($ch);
$err = curl_errno($ch);
curl_close($ch);
return ($err == 0)?$content:false;
}
PHP的getallheader正在恢复
array
'Host' => string 'localhost' (length=9)
'Accept' => string '*/*' (length=3)
'Content-Length' => string '16632433' (length=8)
'Expect' => string '100-continue' (length=12)
'Content-Type' => string 'multipart/form-data; boundary=----------------------------93ac4fed717b' (length=70)
卷曲的curl_getinfo函数返回:
array
'url' => string 'http://localhost/archieve/index.php' (length=35)
'content_type' => string 'application/json' (length=16)
'http_code' => int 200
'header_size' => int 281
'request_size' => int 263
'filetime' => int -1
'ssl_verify_result' => int 0
'redirect_count' => int 0
'total_time' => float 0.125
'namelookup_time' => float 0
'connect_time' => float 0
'pretransfer_time' => float 0
'size_upload' => float 16632433
'size_download' => float 18
'speed_download' => float 144
'speed_upload' => float 133059464
'download_content_length' => float 18
'upload_content_length' => float 16632433
'starttransfer_time' => float 0.015
'redirect_time' => float 0
'certinfo' =>
array
empty
可这porblem由内容类型是事业?我在stackoverflow上阅读,它建议CURL足够聪明,可以自行设置此值。
print_r是你的朋友 –
curl_errno($ ch);返回0.问题是,除了没有提交POST数据之外,所有事情都照常运作。 – thedethfox