PHP code example of lucasguo / yii2-upyun

1. Go to this page and download the library: Download lucasguo/yii2-upyun library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lucasguo / yii2-upyun example snippets


//在config/web.php配置文件中定义component配置信息
'components' => [
  .....
  'upyun' => [
    'class' => 'lucasguo\upyun\UpYun',
    'bucketname' => '空间名称,必填',
    'username' => '操作员账号,必填',
    'password' => '操作员密码,必填',
    'timeout' => '上传请求超时时间,整数,单位秒,选填,默认30',
    'endpoint' => '接入点,选填,选填,默认UpYun::ED_AUTO',
    'basePath' => '上传文件文件夹,如/uploads/,选填,默认/',
    'useOwnDomain' => false;(影响upload方法的返回值,云存储则设为false,自主源则为true)
  ]
  ....
]


$fileUrl = Yii::$app->upyun->upload($file);