PHPackages                             yiiext/file-upload-action - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. yiiext/file-upload-action

ActiveLibrary[File &amp; Storage](/categories/file-storage)

yiiext/file-upload-action
=========================

File upload action

219369PHP

Since Mar 7Pushed 11y ago7 watchersCompare

[ Source](https://github.com/yiiext/file-upload-action)[ Packagist](https://packagist.org/packages/yiiext/file-upload-action)[ RSS](/packages/yiiext-file-upload-action/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

File upload action
==================

[](#file-upload-action)

Usage
-----

[](#usage)

```
// add action to controller
public function actions()
{
	return array(
		// ...
		'upload'=>array(
			'class' => 'ext.yiiext.actions.fileUpload.EFileUploadAction',
			// The data model which contains file attribute with validation rules.
			'model' => null,
			// The model attribute.
			'attribute' => null,
			// The input field name. This must be resolve from model and attribute.
			'name' => 'upload-file',
			// Try create directory if not exists. Defaults to false.
			'createDirectory' => false,
			// Which means the widest possible access.
			'createDirectoryMode' => 0644,
			// Which create directories recursive.
			'createDirectoryRecursive' => false,
			// The rule for generate filename.
			// i.e. 'filenameRule' => 'md5($file->name) . "." . $file->extensionName',
			'filenameRule' => null,
			// The filename. If not set will be copied original filename.
			'filename' => null,
			// The directory where save files.
			'path' => null,
			'onBeforeUpload' => function ($event) {
				// Change default path via event.
				$event->sender->path=Yii::getPathOfAlias('webroot') . '/files';
			},
			'onBeforeSave' => function ($event) {
				// Add error and cancel uploading.
				$event->sender->addError(Yii::t('yiiext', 'Process stopped!'));
				$event->isValid = false;
			},
			'onAfterSave' => function($event) {
				// i.e. make thumb for uploaded image.
			}
			'onAfterUpload' => function ($event) {
				if($event->sender->hasErrors()) {
					// Show error if exists.
					echo implode(', ', $event->sender->getErrors());
				} else {
					// Return url.
					echo str_replace(Yii::getPathOfAlias('webroot'), '', $event->sender->path) . '/' . $event->sender->filename;
				}
				// Stop application.
				exit;
			}
		),
		// ...
	);
}
```

Events
------

[](#events)

Action has 4 events and runs in the following order:

- **onBeforeUpload** - this event is mainly intended to change the default settings for the action: save path, file name, etc.
- **onBeforeSave** - intended for a more detailed validation of the downloaded file, what can be done by means of the model. This event can be canceled to save the file by setting the `$event->isValid = false`
- **onAfterSave** - an event designed to manipulate already saved file.
- **onAfterUpload** - in this event are invited to check the load, save or no. And show the error.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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.

### Community

Maintainers

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

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

---

Top Contributors

[![slavcodev](https://avatars.githubusercontent.com/u/757721?v=4)](https://github.com/slavcodev "slavcodev (9 commits)")[![Ekstazi](https://avatars.githubusercontent.com/u/992738?v=4)](https://github.com/Ekstazi "Ekstazi (3 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (2 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (1 commits)")

### Embed Badge

![Health badge](/badges/yiiext-file-upload-action/health.svg)

```
[![Health](https://phpackages.com/badges/yiiext-file-upload-action/health.svg)](https://phpackages.com/packages/yiiext-file-upload-action)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M123](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M61](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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