0
我試圖發佈文件接收空捲曲響應爲curl_exec和使用curl託管在同一臺機器上的本地圍棋服務器的一些數據:診斷在PHP
// initialise the curl request
$request = curl_init('http://localhost:9049/api');
// send a file
curl_setopt($request, CURLOPT_POST, true);
curl_setopt(
$request,
CURLOPT_POSTFIELDS,
array(
'company' => 'compname',
'user' => 'compuser',
'srv'=> 0,
'colTxt' => 'col1|col2|col3',
'upfile' => '@' . $_FILES['upfile']['tmp_name']
. ';filename=' . $_FILES['upfile']['name']
. ';type=' . $_FILES['upfile']['type']
));
// output the response
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($request);
// close the session
curl_close($request);
不幸的是,上面的代碼是給一個空反應,嘗試了很多種方法,但仍然是一個空洞的迴應。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
即使curl_getinfo($ ch)是空的,所以它很難診斷。雖然似乎沒有網絡問題,因爲我可以從命令行使用curl發佈文件,並且它工作得很好。任何想法,我可能會失蹤?
謝謝。