承接 vinpel/yii2-dropzone 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

vinpel/yii2-dropzone

最新稳定版本:v1.0.5

Composer 安装命令:

composer require vinpel/yii2-dropzone

包简介

DropzoneJs Extention for Yii2 based on Parminder repo

README 文档

README

DropzoneJs Extention for Yii2

A port of DropzoneJs for Yii2 Framework

based from work of Parminder Klair : https://github.com/perminder-klair/yii2-dropzone

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist vinpel/yii2-dropzone "~1.0.4"

or add

"vinpel/yii2-dropzone": "~1.0.4"

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 \vinpel\DropZone::widget();

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

echo \vinpel\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;
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 26
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-10