2017 © Pedro Peláez
 

yii2-extension yii2-fuploader

BlueImp file upload widget for Yii2

image

joni-jones/yii2-fuploader

BlueImp file upload widget for Yii2

  • Thursday, March 24, 2016
  • by joni-jones
  • Repository
  • 2 Watchers
  • 0 Stars
  • 92 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

File Uploader

File uploader. Yii2 extension based on jQuery File Upload Plugin., (*1)

Latest Stable Version Total Downloads License, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist joni-jones/yii2-fuploader "*"

or add, (*5)

"joni-jones/yii2-fuploader": "*"

to the require section of your composer.json file., (*6)

Usage

Once the extension is installed, simply use it in your code by :, (*7)

<?= \jones\fuploader\FileUpload::widget();?>
  1. Specify action property for uploading url:, (*8)

    FileUpload::widget([
        'action' => Url::to(['some_action'])
    ]);
    
  2. Specify any jquery file upload options:, (*9)

    FileUpload::widget([
        'options' => [
            'plugin' => [
                'formData' => 'some data',
            ],
        ],
        'content' => 'Select image',
    ]);
    
  3. To setup plugin events or callbacks - use clientEvents option for widget:, (*10)

    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., (*11)

    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:, (*12)

    public function someCallback($request, $files)
    {
        // some code
    }
    

    UploadAction() return response in json format. This is structure of response:, (*13)

    {"message": "some success message", "files": [{"name": "", "ext": ""}], "url": "url to files directory"}
    
    {"reason": "message with reason why file does not uploaded"}
    

    Also, status codes of response will be returned in headers., (*14)

License

MIT, (*15)

The Versions

24/03 2016

dev-master

9999999-dev

BlueImp file upload widget for Yii2

  Sources   Download

MIT

The Requires

 

by Ievgen Sentiabov

extension yii2 file upload jquery file upload blueimp plugin

06/07 2015

1.1.0

1.1.0.0

BlueImp file upload widget for Yii2

  Sources   Download

MIT

The Requires

 

by Ievgen Sentiabov

extension yii2 file upload jquery file upload blueimp plugin

24/02 2015

1.0.0

1.0.0.0

BlueImp file upload widget for Yii2

  Sources   Download

MIT

The Requires

 

by Ievgen Sentiabov

extension yii2 file upload jquery file upload blueimp plugin