yii2-plupload
A plupload extension for the Yii2 framework, (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist boundstate/yii2-plupload "*"
or add, (*4)
"boundstate/yii2-plupload": "*"
to the require section of your composer.json
file., (*5)
Usage
Action
public function actions() {
return [
'upload' => [
'class' => PluploadAction::className(),
'onComplete' => function ($filename, $params) {
// Do something with file
}
],
];
}
<?= 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");
}'
],
]); ?>