PHPackages                             xj/yii2-dropzone-widget - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xj/yii2-dropzone-widget

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xj/yii2-dropzone-widget
=======================

yii2-dropzone-widget

1.0.5(10y ago)23444BSD-3-ClausePHP

Since Feb 6Pushed 10y ago2 watchersCompare

[ Source](https://github.com/xjflyttp/yii2-dropzone-widget)[ Packagist](https://packagist.org/packages/xj/yii2-dropzone-widget)[ RSS](/packages/xj-yii2-dropzone-widget/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

yii2-dropzone-widget
====================

[](#yii2-dropzone-widget)

yii2-dropzone-widget

composer.json
-------------

[](#composerjson)

```
"require": {
    "xj/yii2-dropzone-widget": "*"
},
```

Action:
-------

[](#action)

```
public function actions() {
return [
    'upload' => [
        'class' => \xj\dropzone\UploadAction::className(),
        'uploadBasePath' => '@webroot/attachment/album', //file system path
        'uploadBaseUrl' => '@web/attachment/album', //web path
//        'format' => '{yyyy}{mm}{dd}/{time}{rand:6}', // OR Closure
        'format' => function(UploadAction $action) {
            $fileext = $action->uploadFileInstance->getExtension();
            $filehash = sha1(uniqid() . time());
            $p1 = substr($filehash, 0, 2);
            $p2 = substr($filehash, 2, 2);
            return "{$p1}/{$p2}/{$filehash}.{$fileext}";
        },
        'validateOptions' => [
            'extensions' => ['jpg', 'png'],
            'maxSize' => 1 * 1024 * 1024, //file size
        ],
        'beforeValidate' => function($action) {
            $id = Yii::$app->request->get('id');
            if ($id === null) {
                throw new \yii\base\Exception('错误的ID');
            }
            if (Something::findOne($id) === null) {
                throw new \yii\base\Exception('错误的ID');
            }
        },
        'afterValidate' => function($action) {
            //something
        },
        'beforeSave' => function($action) {
            //something
        },
        'afterSave' => function($action) {
            /* @var $action xj\uploadify\UploadAction */
//resize image
            $id = Yii::$app->request->get('id');
            $srcFilename = $action->getUploadFileInstance()->name;
            $image = \xj\kohanaimage\Image::load($action->fullFilename);
            if ($image->width > 1280) {
                $image->resize(1280, NULL)->save();
            }
//insert image to Tables
            $photoModel = Photo::addByImage($action->fullFilename, $action->filename, $id, $srcFilename);
            $action->output['id'] = $photoModel->id;
        },
    ],
];
}
```

View
----

[](#view)

```
Dropzone::widget([
    'url' => ['upload', 'id' => $model->id],
    'id' => 'album-upload',
    'jsOptions' => [
        'previewTemplate' => '',
        'success' => new JsExpression( ['id' => 'album-upload-dropzone'],
    'formOptions' => ['class' => 'album-upload-dropzone dz-clickable'],
]);
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

6

Last Release

4013d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9f04ccc1ccda3af80975323425ff7d5f7d142603f1ad05df6558ffa63256f8d?d=identicon)[xjflyttp](/maintainers/xjflyttp)

---

Top Contributors

[![xjflyttp](https://avatars.githubusercontent.com/u/128428?v=4)](https://github.com/xjflyttp "xjflyttp (10 commits)")

### Embed Badge

![Health badge](/badges/xj-yii2-dropzone-widget/health.svg)

```
[![Health](https://phpackages.com/badges/xj-yii2-dropzone-widget/health.svg)](https://phpackages.com/packages/xj-yii2-dropzone-widget)
```

###  Alternatives

[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
