帖子
帖子
用户
博客
课程
显示全部楼层
2
帖子
0
勋章
18
Y币

[云开发] 使用PHP curl上传图片总是提示Errno:couldn't open file

[复制链接]
发表于 2015-5-5 14:56:56
<?php
function getMillisecond() {
        list($s1, $s2) = explode(' ', microtime());
        return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}

function intiCurl($method,$class,$content,$id){
        $time = getMillisecond();
        $AppID = 'xxxx';
        $AppKey = 'xxxxxxx';
        $AppPath = 'https://d.apicloud.com/mcm/api/file';
        $shaKey = sha1($AppID.'UZ'.$AppKey.'UZ'.$time).'.'.$time;
        $ch = curl_init();
        $timeout = 30;  
        $headerinfo = array(
                //'Content-Type:application/json',
                'application/x-www-form-urlencoded',
                'X-APICloud-AppId:'.$AppID,
                'X-APICloud-AppKey:'.$shaKey,

        );

     
        curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt ( $ch, CURLOPT_POST, 1 );
        curl_setopt ($ch, CURLOPT_URL, $AppPath);  
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt ($ch, CURLOPT_HTTPHEADER, $headerinfo);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST,  FALSE);
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        
        $post_data = array("file" =>"@","filename"=>"{{67.jpg}}","type"=>"{{jpg}}"
        );
        print_r($post_data);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data);
        $file_contents = curl_exec($ch);
        if (curl_errno($ch)) {         
                echo 'Errno:'.curl_error($ch)."<Br/>";//捕抓异常     
        }
        curl_close($ch);  

        return $file_contents;

}

echo intiCurl('POST','','xxxxxx','');
?>


这个是 自己的代码问题,还没到我们的云数据服务器.请知晓
2
帖子
0
勋章
18
Y币
提示 { "status": 0, "code": 120 } 呢?
7
帖子
0
勋章
1594
Y币
ameson 发表于 2015-5-5 22:39
提示 { "status": 0, "code": 120 } 呢?

检查你的上传文件,
120:"文件不存在",
您需要登录后才可以回帖 登录

本版积分规则