Skip to content

Commit

Permalink
docs(readme): improve usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejpeters committed Aug 11, 2015
1 parent c691a90 commit 95540ae
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,48 @@ to the require section of your `composer.json` file.

## Usage

Once the extension is installed, simply create an upload button with:
### Action

```php
<?= \boundstate\plupload\Plupload::widget(); ?>
public function actions() {
return [
'upload' => [
'class' => PluploadAction::className(),
'onComplete' => function ($filename, $params) {
// Do something with file
}
],
];
}
```

### Widget

```php
<?= 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");
}'
],
]); ?>
```

0 comments on commit 95540ae

Please sign in to comment.