yii2-qiniu 七牛图片上传

作者: cheng 发布时间: 2017-03-25 浏览: 920 次 编辑

yii2-qiniu

file upload for Yii Framework 2

php > 5.5

How to install? To use this extension, you may insert the following code:

Get it via composer by adding the package to your composer.json:

{  
    "require": {   
         "crazyfd/yii2-qiniu": "dev-master"
     }
}
php composer.phar update

Usage

<?php
    $ak = 'sss';
    $sk = 'sss';
    $domain = 'http://demo.domain.com/';
    $bucket = 'demo';
    use crazyfd\qiniu\Qiniu;
    $qiniu = new Qiniu($ak, $sk,$domain, $bucket);
    $key = time();
    $qiniu->uploadFile($_FILES['tmp_name'],$key);
    $url = $qiniu->getLink($key);