-
使用 composer 安装
composer require sczts/laravel-upload
-
发布配置文件
php artisan vendor:publish --provider="Sczts\Upload\Providers\UploadProvider"
-
向
.env
添加环境变量# 上传配置 UPLOAD_DRIVER=qiniu QINIU_AK=xxxxxxxxxxxxxx QINIU_SK=xxxxxxxxxxxxx QINIU_BUCKET=xxxx QINIU_DOMAIN=http://cdn.xxxxxxx.com
-
使用
例 (依赖注入):
use Sczts\Upload\Upload; class CommonController extends Controller { // 上传文件 public function upload(Request $request,Upload $upload) { $file = $request->file('file'); $data = $upload->upload($file); return $this->json(StatusCode::SUCCESS, $data); } }
例 (门面):
use Sczts\Upload\Facades\Upload; class CommonController extends Controller { // 上传文件 public function upload(Request $request) { $file = $request->file('file'); $data = Upload::upload($file); return $this->json(StatusCode::SUCCESS, $data); } }
-
按实际需求修改
config/upload.php
配置,可在channel
中覆盖settings
的配置
-
Notifications
You must be signed in to change notification settings - Fork 1
laravel 七牛云上传
License
sczts/laravel-upload
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|