卷曲在localhost上工作但不在服务器上工作

时间:2017-02-06 06:47:31

标签: php codeigniter curl php-curl

所以这是我的问题...我有一个php-curl函数,它将一个POST请求发送到API,文件作为参数。 我的代码在localhost上运行得非常好,而且它在我的服务器上无法运行。

服务器详情   - 专用VPS Windows Server 2012   - 安装了PHP 5.5和MySQL 5.5以及phpmyadmin   - 启用卷曲...&&尝试了一个简单的卷曲功能,它的工作正常 我的应用   - 我的代码在localhost上运行得很好,但是它不能在服务器上工作(我尝试了多个具有多个规格的服务器)

 $localFile=$_FILES['file_c']['tmp_name'];

    $curl = curl_init($url);

     if ((version_compare(PHP_VERSION, '5.5') >= 0)) {
         $data = array(
            'version' => '2017-01-20',
            'file' => new CURLFile($localFile),

            'config'=> '{"conversion_target":"normalized_html"}'
        );
       curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
       }else{
        $data = array(
            'version' => '2017-01-20',
            'file' => "@".$localFile,

            'config'=> '{"conversion_target":"normalized_html"}'
        );
        curl_setopt($curl, CURLOPT_SAFE_UPLOAD, false);

    }



    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");

    curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);  
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);  // Insert the data


    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);


    // Send the request
    if(!curl_exec($curl)){

    die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl));

    }else{ //do something else}

所以这段代码在localhost上工作正常,但在服务器上它会发出500内部服务器错误

服务器日志中没有错误 我已经跟踪了代码中的每一行,它在curl执行行中断开了

请帮忙 谢谢!

0 个答案:

没有答案
相关问题