安装命令行
如果需要上传到云存储,需要安装对应 laravel storage
的适配器
composer require zgldh/qiniu-laravel-storage:0.10.3
同样配置好 disk,在 config/filesystems.php 添加一项:
同样配置好 disk,在 config/filesystems.php 添加一项:
'disks' => [
... ,
'qiniu' => [
'driver' => 'qiniu',
'domains' => [
'default' => 'xxxxx.com1.z0.glb.clouddn.com', //你的七牛域名
'https' => 'dn-yourdomain.qbox.me', //你的HTTPS域名
'custom' => 'static.abc.com', //你的自定义域名
],
'access_key'=> '', //AccessKey
'secret_key'=> '', //SecretKey
'bucket' => '', //Bucket名字
'notify_url'=> '', //持久化处理回调地址
'url' => 'http://of8kfibjo.bkt.clouddn.com/', // 填写文件访问根url
],
],
然后修改 dcat-admin
的上传配置,打开 config/admin.php
找到:
'upload' => [
'disk' => 'qiniu',
'directory' => [
'image' => 'image',
'file' => 'file',
],
],
disk
选择上面配置的 qiniu
,或:
若报错
ErrorException: Undefined index: custom in file D:\phpstudy_pro\WWW\blog2\vendor\zgldh\qiniu-laravel-storage\src\QiniuAdapter.php on line 59
解决方法