emnabs / yii2-plupload
Yii2 Plupload Widget
Installs: 174
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
pkg:composer/emnabs/yii2-plupload
Requires
- bower-asset/plupload: 2.3.6
 - yiisoft/yii2: ~2.0.14
 
README
yii2-plupload is a widget based plupload solution for Yii2. It is released under the BSD 3-Clause license.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist emnabs/yii2-plupload "*"
or add
"emnabs/yii2-plupload": "*"
to the require section of your composer.json.
Usage
To use this widget, you have to add the code in your viewer page:
Usage With ActiveForm and model
use emhome\plupload\Plupload;
echo $form->field($model, 'thumb')->widget(Plupload::classname(), [
    'url' => ['upload'],
    //'wrapperOptions' => ['width' => 200, 'height' => 200],
    //'resize' => ['width' => 200, 'height' => 200],
    'autoUpload' => true,
    'options' => [
        'filters' => [
            'mime_types' => [
                [
                    'title' => "Image files",
                    'extensions' => "jpg,gif,png"
                ],
            ]
        ],
    ],
]);
Usage Without ActiveForm model
use emhome\plupload\Plupload;
Plupload::widget([
    'url' => ['upload'],
    'browseLabel' => '上传文件',
    'autoUpload' => true,
    'errorContainer' => 'errorUpload',
    'options' => [
        'filters' => [
            'max_file_size' => '20kb',
            'mime_types' => [
                [
                    'title' => "Image files",
                    'extensions' => "jpg,gif,png"
                ],
            ]
        ],
    ],
    'events' => [],
]);
Usage actions with PluploadAction
public function actions() { return [ ... 'plupload' => [ 'class' => 'emhome\plupload\PluploadAction', 'onComplete' => function($file, $params) { //上传完成后操作 ... return [ 'file' => $file, 'params' => $params ]; }, ], ... ]; }
License
yii2-plupload is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.
Plupload
Copyright 2016, Ephox
Released under GPLv2 License