Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joni-jones/yii2-fuploader
BlueImp file upload extension for Yii2
https://github.com/joni-jones/yii2-fuploader
file-upload yii2 yii2-extension
Last synced: 14 days ago
JSON representation
BlueImp file upload extension for Yii2
- Host: GitHub
- URL: https://github.com/joni-jones/yii2-fuploader
- Owner: joni-jones
- License: mit
- Created: 2015-01-07T20:47:38.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-24T19:29:19.000Z (over 8 years ago)
- Last Synced: 2024-10-07T17:01:11.369Z (about 1 month ago)
- Topics: file-upload, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
File Uploader
=============File uploader. Yii2 extension based on [jQuery File Upload Plugin](https://github.com/blueimp/jQuery-File-Upload).
[![Latest Stable Version](https://poser.pugx.org/joni-jones/yii2-fuploader/v/stable)](https://packagist.org/packages/joni-jones/yii2-fuploader)
[![Total Downloads](https://poser.pugx.org/joni-jones/yii2-fuploader/downloads)](https://packagist.org/packages/joni-jones/yii2-fuploader)
[![License](https://poser.pugx.org/joni-jones/yii2-fuploader/license)](https://packagist.org/packages/joni-jones/yii2-fuploader)Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist joni-jones/yii2-fuploader "*"
```or add
```
"joni-jones/yii2-fuploader": "*"
```to the require section of your `composer.json` file.
Usage
-----Once the extension is installed, simply use it in your code by :
```php
= \jones\fuploader\FileUpload::widget();?>
```1. Specify `action` property for uploading url:
```php
FileUpload::widget([
'action' => Url::to(['some_action'])
]);
```
2. Specify any jquery file upload options:```php
FileUpload::widget([
'options' => [
'plugin' => [
'formData' => 'some data',
],
],
'content' => 'Select image',
]);
```
3. To setup plugin events or callbacks - use `clientEvents` option for widget:```php
FileUpload::widget([
'clientEvents' => [
'done' => 'function(e, data){console.log(data);}',
'fail' => 'function(e, data){console.log(data);}'
]
]);
```
4. Also you can use extension actions to store some file details after uploading. For example, update user avatar attribute in database.```php
public function actions()
{
return[
'some_action' => [
'class' => 'jones\fuploader\actions\UploadAction',
'path' => 'some path for uploading',
'url' => 'some url for uploaded file', //this url will be accessable in action response
'callback' => [$this, 'someCallback'] //any callable function
]
];
}
```
5. If callback was specified it will be triggered after uploading:
```php
public function someCallback($request, $files)
{
// some code
}
```
`UploadAction()` return response in json format. This is structure of response:
```json
{"message": "some success message", "files": [{"name": "", "ext": ""}], "url": "url to files directory"}
```
```json
{"reason": "message with reason why file does not uploaded"}
```
Also, status codes of response will be returned in headers.License
----MIT