dev-master
9999999-devyii2-dropzone
Apache-2.0
The Requires
by zzbajie
extension yii2
yii2-dropzone
yii2-dropzone, (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist zzbajie/yii2-dropzone "dev-master"
or add, (*4)
"zzbajie/yii2-dropzone": "*"
to the require section of your composer.json
file., (*5)
Once the extension is installed, simply use it in your code by :, (*6)
php
<?= \zzbajie\dropzone\DropZone::widget(
[
'name' => 'img', // input name or 'model' and 'attribute'
'url' => 'upload-main', // upload url
'storedFiles' => [
], // stores files
'eventHandlers' => [], // dropzone event handlers
'sortable' => false, // sortable flag
'sortableOptions' => [], // sortable options
'htmlOptions' => [
], // container html options
'options' => [
'params' => ['productId' => $model->id,],
//'addRemoveLinks' => true,
//'dictRemoveFile' => "删除",
'dictCancelUpload' => "取消",
'dictDefaultMessage' => '<button class="btn btn-default btn-flat" type="button" id="submit-img-btn">点击或拖拽图片到这里 (<span style="color:#7e0099;"> 宽600px * 高600px </span>)</button>',
'acceptedFiles' => "image/*",
'uploadMultiple' => false,
], // dropzone js options
'eventHandlers' => [
'complete' => "function(file){console.log(file)}",
'removedfile' => "function(file){alert(file.name + ' is removed')}",
//'sending' => "function(file, xhr, formData){formData.append('" . Yii::$app->request->csrfParam . "','" . Yii::$app->request->getCsrfToken() . "')}"
]
]
);
?>
, (*7)
yii2-dropzone
Apache-2.0
extension yii2