编程语言
首页 > 编程语言> > think PHP6 云端上传图片 七牛云 腾讯云

think PHP6 云端上传图片 七牛云 腾讯云

作者:互联网

1.composer:

composer require lorine/oss-utils

2.控制器方法代码:

use Lorine\OssUtils\OssService;
function yun(){
    $config = [
        'ak' => 'xxxxx',//SecretId /Access_Key
        'sk' => 'xxxxx',//SecretKe /Secret_Key
        'bucket' => 'xxx',//桶名 /空间名
        'region' => 'ap-shanghai'//地区 七牛云为'',腾讯云在控制台对象存储界面获取,如上海(ap-shanghai)
    ];

    try {
        //云存储类型 腾讯云:Tencent  七牛云:Qiniu
        $obj = (new OssService())->getOssService('Qiniu');
        //$tmpName绝对路径
        //$fileName自定义云储存的文件名称
        //$res = $obj->uploadFile($config,$tmpName,$fileName);
        $res = $obj->uploadFile($config,'D:\phpstudy_pro\WWW\five\tp6\public\11111.png','123');
        dd($res);
    }catch (Exception $exception){
        dd($exception->getMessage());
    }
}

 3.上传成功示例:

  

标签:obj,res,Qiniu,ap,腾讯,七牛云,PHP6,config,think
来源: https://blog.csdn.net/a18132147899/article/details/121949246