boundstate/yii2-plupload

The plupload extension for the Yii framework

Installs: 3 816

Dependents: 1

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 5

Open Issues: 2

Type:yii2-extension

v0.0.2 2015-08-11 21:32 UTC

This package is auto-updated.

Last update: 2024-11-09 00:47:01 UTC


README

A plupload extension for the Yii2 framework

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist boundstate/yii2-plupload "*"

or add

"boundstate/yii2-plupload": "*"

to the require section of your composer.json file.

Usage

Action

public function actions() {
    return [
        'upload' => [
            'class' => PluploadAction::className(),
            'onComplete' => function ($filename, $params) {
                // Do something with file
            }
        ],
    ];
}

Widget

<?= Plupload::widget([
    'url' => ['upload'],
    'browseLabel' => 'Upload',
    'browseOptions' => ['id' => 'browse', 'class' => 'btn btn-success'],
    'options' => [
        'filters' => [
            'mime_types' => [
                ['title' => 'Excel files', 'extensions' => 'csv,xls,xlsx'],
            ],
        ],
    ],
    'events' => [
        'FilesAdded' => 'function(uploader, files){
            $("#error-container").hide();
            $("#browse").button("loading");
            uploader.start();
        }',
        'FileUploaded' => 'function(uploader, file, response){
            $("#browse").button("reset");
        }',
        'Error' => 'function (uploader, error) {
            $("#error-container").html(error.message).show();
            $("#browse").button("reset");
        }'
    ],
]); ?>