yii2-plupload is a widget based plupload solution for Yii2. It is released under the BSD 3-Clause license.
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.
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
];
},
],
...
];
}
yii2-plupload is released under the BSD 3-Clause
License. See the bundled LICENSE.md
for details.
Copyright 2016, Ephox
Released under GPLv2 License