dougong1031 2015-12-21 17:05
浏览 46

PHP中的cURL问题,无论如何都返回false

So I'm rather new to using cURL in PHP, I was told to use it for a task this week and it's been nothing but a pain, and I can't seem to find a solution to my problem no matter how hard I search.

What I am attempting to do is send a file to an upload directory on my hosted server from a remote portal manager that I have built. The file uploadhandler in the portal manager connects via curl to the remote destination and then the remote destination grabs the info and processes the file like normal. No matter what I've been trying though everything just throws back a failed response.

Here is the updated version of the code I am working with

updates

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, false);
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt(
    $ch, 
    CURLOPT_POSTFIELDS, 
    array(
        'file' => 
            '@'             .$_FILES['doc']['tmp_name'][$i]
            .';filename='   .$_FILES['doc']['name'][$i]
            .';type='       .$_FILES['doc']['type'][$i]
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//$response = curl_exec($ch);
if(curl_exec($ch) === false){
    echo curl_error($ch);
    echo curl_errno($ch);
}else{
    echo "ok";
}

With all of this information set I am getting no value for curl_error but I get a value of 43 for curl_errno.

From what I have been researching, error 43 for curl is

CURLE_BAD_FUNCTION_ARGUMENT (43)
Internal error. A function was called with a bad parameter.

However all my functions for the curl_setopt() are put together correctly based on the info from php.net. So this is where I am now confused, because I have no idea what is causing this to happen. Thanks again for the help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line