1.百度搜索‘七牛云’,注册账号
2.
3.创建成功
4.
5.
6.
7.
9.
10.
thinkPHP6的代码 以及扩展安装
先安装扩展
两条命令:
# 安装扩展
composer require death_satan/think-qiniu-storage
composer require overtrue/laravel-filesystem-qiniu
11.config配置文件
'qiniu' => [
'type'=>'qiniu',
'accessKey'=>'…………………………',//你的accessKey
'secretKey'=>'…………………………',//你的secretKey
'bucket'=>'…………………………',//你的存储空间名
'domain'=>'…………………………' //你的七牛云加速域名
],
12.控制器
public function uploadImage(){
$image = \request()->all('image');
$path = Filesystem::disk('qiniu')->putFile(date('Y-m-d'),$image,'uniqid');
return json([
'code'=>200,
'msg'=>'上传七牛成功',
'data'=>[
'path'=>$path,
]
]);
}