我的卷曲课:
class curlpost{
function setoptions($option=array()){
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $option['url']);
curl_setopt($ch, CURLOPT_HEADER, $option['header']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $option['postfields']);
curl_setopt($ch, CURLOPT_INFILESIZE, $option['filesize']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return curl_exec($ch) ;
}
}
我正在使用CodeIgniter框架开发一个项目。当我在localhost环境中的代码中调用此类中的方法时,它工作正常,但在实时服务器中,我得到500 internal server error
。
实时服务器中curl_getinfo($ch)
的结果:
Array ( [url] => http://liveserver/uploader/do_upload [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0.021748 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ( ) [redirect_url] => )
本地服务器中curl_getinfo($ch)
的结果:
Array ( [url] => http://localserver/uploader/do_upload [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 611 [request_size] => 210 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.20281 [namelookup_time] => 0.000321 [connect_time] => 0.000428 [pretransfer_time] => 0.000429 [size_upload] => 79372 [size_download] => 476 [speed_download] => 2347 [speed_upload] => 391361 [download_content_length] => 476 [upload_content_length] => 79372 [starttransfer_time] => 0.001535 [redirect_time] => 0 [certinfo] => Array ( ) [redirect_url] => )
答案 0 :(得分:0)
我认为问题是因为您的服务器上未安装curl
。试试这个:
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
function _isCurl(){
return function_exists('curl_version');
}
检查是否安装了curl
。如果没有安装它,请重试。