laravel-10图片上传插件

当前插件集成了七牛云、阿里云、腾讯云对象存储,只需简单配置即可使用这三个oss服务,支持laravel 9版本以上.
github 地址:https://github.com/yreborn/laravel-upload

下载方式:

1、通过composer下载:composer require yreborn/laravel-upload
2、在composer.json 新增 "yreborn/laravel-upload": "dev-main",在命令行使用composer install进行安装

1、创建config/upload.php 配置文件

 '密钥id',
    'ali_access_key_secret' => '密钥',
    'ali_endpoint'          => '区域域名',
    'ali_bucket'            => 'bucket列表',
    'ali_http'              => '访问域名',

    'qn_access_key'         => '密钥id',
    'qn_secret_key'         => '密钥',
    'qn_bucket'             => 'bucket列表',
    'qn_http'               => '访问域名1',

    'tx_secret_id'          => '密钥id',
    'tx_secret_key'         => '密钥',
    'tx_region'             => '区域',
    'tx_bucket'             => 'bucket列表',
    'tx_http'               => '访问域名'
];

2、在config/app目录加载插件

    'providers' => [
        Yreborn\LaravelUpload\UploadServiceProvider::class
    ],
    'aliases' => [
        'Upload' => Yreborn\LaravelUpload\Facades\Upload::class
    ],

3、在控制器使用

    file('file')->store('file');
            $local_path = Storage::path($oss_path);
            $res = Upload::aliUpload($local_path,$oss_path);
            return $res;
        }
    }

你可能感兴趣的:(laravel,php)