emnabs/yii2-plupload

Yii2 Plupload Widget

Installs: 174

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.2.9 2021-03-11 16:18 UTC

This package is auto-updated.

Last update: 2024-11-12 00:08:26 UTC


README

yii2-plupload is a widget based plupload solution for Yii2. It is released under the BSD 3-Clause license.

Latest Stable Version Total Downloads 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