thinkphp6整合文件上传,七牛云
composer下载包
composer require death_satan/think-qiniu-storage -vvv
编辑 项目config目录下的filesystem.php文件
<?php
use think\facade\Env;
return [
'default' => Env::get('filesystem.driver', 'local'),
'disks' => [
'local' => [
'type' => 'local',
'root' => app()->getRuntimePath() . 'storage',
],
'public' => [
'type' => 'local',
'root' => app()->getRootPath() . 'public/storage',
'url' => '/storage',
'visibility' => 'public',
],
'qiniu'=>[
'type'=>'qiniu',
'accessKey'=>'your accessKey',
'secretKey'=>'your secretKey',
'bucket'=>'your qiniu bucket name',
'domain'=>'your qiniu bind domain'
]
],
];
配置完后在控制器中使用
<?php
namespace app\controller;
use app\BaseController;
class Index extends BaseController
{
public function index()
{
$image = $this->request->file('image');
$qiniu_file = \think\facade\Filesystem::disk('qiniu')->putFile('image',$image);
dd($qiniu_file);
}
}