joni-jones/yii2-fuploader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

joni-jones/yii2-fuploader

最新稳定版本:1.1.0

Composer 安装命令:

composer require joni-jones/yii2-fuploader

包简介

BlueImp file upload widget for Yii2

README 文档

README

File uploader. Yii2 extension based on jQuery File Upload Plugin.

Latest Stable Version Total Downloads License

Installation

The preferred way to install this extension is through composer.

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 :

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

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

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

    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.

    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:

    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

统计信息

  • 总下载量: 107
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-08