上传图片开启本地ssl证书bug问题

bug描述

第一个报错,当我正确配置证书了,就出现第二个报错了
cURL error 60: SSL certificate problem: self signed certificate in certifica 【已解决】

第二个报错
ErrorException: Array to string conversion in C:\draw_webman\webman\vendor\workerman\workerman\Protocols\Http.php:209
Stack trace:【未解决】

0 C:\draw_webman\webman\vendor\workerman\workerman\Protocols\Http.php(209): support\App::{closure}(8, 'Array to string...', 'C:\draw_webman\...', 209, Array)

程序代码或配置

证书配置检查多次确信无误

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="D:/phpstudy_pro/Extensions/php/php7.4.3nts/extras/ssl/cacert.pem"

[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile="D:/phpstudy_pro/Extensions/php/php7.4.3nts/extras/ssl/cacert.pem"

期待的结果及实际结果

框架报错行数

截图

系统环境及workerman/webman等具体版本

这里写具体的系统环境相关信息
截图

备注:自己已检测业务代码,不应该是业务代码错误,业务代码是从原生tp5复制过来的

//上传图片
    public function upload(Request $request)
    {
        $file = $request->file('file');
        if ($file && $file->isValid()) {
            $info =  $file->move(public_path().'/files/myfile.'.$file->getUploadExtension());
            $fi = './public/files/myfile.'.$file->getUploadExtension();

        $savePath =  time().mt_rand(100000,999999).'.png'; 
        //将图片传到腾讯云
        $local_path  = $fi;//文件上传临时目录
        //抠图完成上传腾讯云,加快下载速度
        $server_key_name = '/photo/'.date("Ymd",time()).'/'.date("YmdHis",time()).$savePath;//远程服务器存储的名字
        require './vendor/autoload.php';

        $secretId = "XXX"; //"云 API 密钥 SecretId";
        $secretKey = "XXX"; //"云 API 密钥 SecretKey";改成自己的
        $region = "ap-nanjing"; //设置一个默认的存储桶地域
        $cosClient = new \Qcloud\Cos\Client(
            array(
                'region' => $region,
                'schema' => 'https', //协议头部,默认为http
                'credentials'=> array(
                    'secretId'  => $secretId ,
                    'secretKey' => $secretKey)
            )
        );

        //定义数据
        $upload_success = false;
        $img_url = '';
        $upload_msg = '';

        try {
            $result = $cosClient->upload(
                $bucket = 'xxx-123', //请创建桶的时候 设置公共读写  改成自己的
                $key = $server_key_name,
                $body = fopen($local_path, 'rb')
            );
            // 请求成功,返回透明前景
            $data = $result->toArray() ;
            return $data;
            if(isset($data['Location']) && isset($data['Key'])){
                $img_url = 'https://'.$data['Location'];
                $upload_success = true;
            }
        } catch (\Exception $e) {
            // 请求失败
            $upload_msg = $e->getMessage();
            return $upload_msg;
        }
        //合成成功
        $data = ['img_url'=>$img_url];
        return $data;
    }
    }
937 2 0
2个回答

PHP甩JAVA一条街

上传图片的业务代码,在我原生tp5里面执行正常,复制到webman,报框架错误,框架错误让我无从下手,有人遇到此类情况吗?

  • 暂无评论
抽不完的寂寞

关键字 Array to string... ,数组不能转换为字符串。控制器里return array应该是错误用法,改成 return json($data); 试下

  • PHP甩JAVA一条街 2023-01-04

    谢谢大佬点拔, 果然是的,报框架错误,我没法定位哪里的问题,按道理应该报我代码错误,不过,非常感谢大佬

年代过于久远,无法发表回答
×
🔝