第一步:下载sdk
第二步:
将下载下来的文件,重命名为:alioss,放在extend文件夹下面
第三步:
在application下配置文件config.php中添加
//阿里云资源服务器配置,里面填写你们自己的oss账号的相关信息 'aliyunOss'=>[ 'KeyId' => '', 'KeySecret' =>'', 'Endpoint' => '', 'Bucket'=> '' ]
第四步:
编写文件上传类
<?php namespace app\common\controller; use think\Controller; use think\Config; use think\Image; use OSS\OssClient; use OSS\Core\OssException; class Alioss extends Controller { /* 测试函数 public function index(){ return $this->fetch('user/index'); }*/ /** * 单文件上传 * $file = request()->file('file'); //