定制 perminder-klair/yii2-dropzone 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

perminder-klair/yii2-dropzone

最新稳定版本:v1.0.1

Composer 安装命令:

composer require perminder-klair/yii2-dropzone

包简介

DropzoneJs Extention for Yii2

README 文档

README

DropzoneJs Extention for Yii2

A port of DropzoneJs for Yii2 Framework

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist perminder-klair/yii2-dropzone "dev-master"

or add

"perminder-klair/yii2-dropzone": "dev-master"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by to create Ajax upload area :

echo \kato\DropZone::widget();

To pass options : (More details at dropzonejs official docs )

echo \kato\DropZone::widget([
       'options' => [
           'maxFilesize' => '2',
       ],
       'clientEvents' => [
           'complete' => "function(file){console.log(file)}",
           'removedfile' => "function(file){alert(file.name + ' is removed')}"
       ],
   ]);

Example of upload method :

public function actionUpload()
{
    $fileName = 'file';
    $uploadPath = './files';

    if (isset($_FILES[$fileName])) {
        $file = \yii\web\UploadedFile::getInstanceByName($fileName);

        //Print file data
        //print_r($file);

        if ($file->saveAs($uploadPath . '/' . $file->name)) {
            //Now save file data to database

            echo \yii\helpers\Json::encode($file);
        }
    }

    return false;
}

统计信息

  • 总下载量: 233.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 54
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 50
  • Watchers: 8
  • Forks: 26
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-11