andru19 / yii2-dropzone
Yii2 Dropzone 小部件
dev-master
2016-05-30 21:18 UTC
Requires
- bower-asset/dropzone: 4.0.1
- yiisoft/yii2: 2.0.*
Requires (Dev)
- yiisoft/yii2-debug: 2.0.*
This package is not auto-updated.
Last update: 2024-09-14 16:34:38 UTC
README
此扩展为 Yii2 框架提供了 Dropzone 集成。
安装
此扩展需要 Dropzone
安装此扩展的首选方式是通过 composer。
运行以下命令之一
php composer.phar require --prefer-dist andru19/yii2-dropzone "*"
或添加
"andru19/yii2-dropzone": "*"
到您的 composer.json 文件的 require 部分。
到您的 composer.json
文件的 require 部分。
使用方法
扩展安装完成后,只需在您的代码中使用它来创建 Ajax 上传区域
echo \andru\dropzone\DropZone::widget();
一般使用方法
use andru\dropzone\DropZone; DropZone::widget( [ 'name' => 'file', // input name or 'model' and 'attribute' 'url' => '', // upload url 'storedFiles' => [], // stores files 'eventHandlers' => [], // dropzone event handlers 'sortable' => true, // sortable flag 'sortableOptions' => [], // sortable options 'htmlOptions' => [], // container html options 'options' => [], // dropzone js options ] ) echo \andru\dropzone\DropZone::widget([ 'options' => [ 'maxFilesize' => '2', ], 'clientEvents' => [ 'complete' => "function(file){console.log(file)}", 'removedfile' => "function(file){alert(file.name + ' is removed')}" ], ]); you can also register `andru\dropzone\UploadAction` and `andru\dropzone\RemoveAction` actions in your controller