Skip to content

mztest/yii2-widget-upload-oss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-widget-upload-oss

A widget for uploading files to AliYun OSS

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require mztest/yii2-widget-upload-oss

or add

"mztest/yii2-widget-upload-oss": "*"

to the require section of your composer.json file.

Usage

  1. Set signature action at your controller

    public function actions()
    {
        return [
            'upload' => [
                'oss-signature' => [
                    'class' => 'mztest\uploadOSS\actions\Signature',
                    'accessKeyId' => 'Your aliyunOSS access key id here.',
                    'accessKeySecret' => 'Your aliyunOSS access secret id here.',
                    'host' => 'Your aliyunOSS upload bucket url',
                ],
            ],
        ];
    }
  2. Simply use it in your code by :

    <?= \mztest\uploadOSS\FileUploadOSS::widget(); ?>

    or

    <?= $form->field($model, 'url')->widget(FileUploadOSS::className(), [
        'signatureAction' => ['oss-signature']
    ]) ?>