PHPackages                             freddyouellette/php-files-normalizer - 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. freddyouellette/php-files-normalizer

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

freddyouellette/php-files-normalizer
====================================

Normalizes the PHP $\_FILES array to a friendlier format.

1.1.0(5y ago)074MITPHP

Since Jun 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/freddyouellette/php-files-normalizer)[ Packagist](https://packagist.org/packages/freddyouellette/php-files-normalizer)[ RSS](/packages/freddyouellette-php-files-normalizer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (3)Used By (0)

PHP $\_FILES Array Normalizer
=============================

[](#php-_files-array-normalizer)

$\_FILES in PHP is not a friendly array, especially when POSTing multiple files or using file inputs with nested names like `layer[][file]`. The `PHP $_FILES Array Normalizer` will normalize the $\_FILES array to the following format:

```
[
	'files' => [
		0 => [
			'name' => 'file1.png',
			'type' => 'image/png',
			'tmp_name' => '/tmp/phpxbbHdC',
			'error' => 0,
			'size' => 11393,
		],
		1 => [
			'name' => 'file2.png',
			'type' => 'image/png',
			'tmp_name' => '/tmp/phpajPldE',
			'error' => 0,
			'size' => 11393,
		],
	],
]

```

And if you are using nested file inputs with names like `layer[0][file]` and `layer[0][other][file]`, the format will be as follows:

```
[
	'layer' => [
		0 => [
			'file' => [
				0 => [
					'name' => 'file1.png',
					'type' => 'image/png',
					'tmp_name' => '/tmp/phpxbbHdC',
					'error' => 0,
					'size' => 11393,
				],
			],
			'other' => [
				'file' => [
					0 => [
						'name' => 'file1.png',
						'type' => 'image/png',
						'tmp_name' => '/tmp/phpxbbHdC',
						'error' => 0,
						'size' => 11393,
					],
				],
			],
		],
	],
]

```

Things to consider:

- The normalizer will **treat all file inputs as if they were `multiple`.** That means that the final `files` layer will always be an array of files, even if only one file was POSTed.
- Don't forget to add the `multiple` attribute and `[]` to the end of your input name when you want multiple files.

Usage
=====

[](#usage)

Install via composer:

```
composer require freddyouellette/php-files-normalizer

```

and in your php file:

```
// require composer autoloader
require_once __DIR__.'/vendor/autoload.php';

// include the Normalizer namespace
use \freddyouellette\PhpFilesNormalizer\PhpFilesNormalizer;

// normalize the $_FILES array
$files = PhpFilesNormalizer::normalize($_FILES);
```

If you would rather merge the $\_FILES array into an existing one, just pass the existing array as the second argument:

```
$files = ['other-data' => 12345];
$files = PhpFilesNormalizer::normalize($_FILES, $files);
```

This can be useful to normalize all data passed from the frontend to a single array. Then your backend controllers can be passed a single array of data instead of having a direct dependency between the *controller* and the *data type* it relies on.

```
$data = array_merge($_POST, $_GET);
$data = PhpFilesNormalizer::normalize($_FILES, $data);
// some controller which accepts data as an argument
$Controller->__invoke($data);
```

Contributing
============

[](#contributing)

I encourage all issues to be submitted through the [**Issues** tab on GitHub](https://github.com/freddyouellette/php-files-normalizer/issues). Pull requests are welcome.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

2164d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

arrayfilesfriendliernormalizationphpupload

### Embed Badge

![Health badge](/badges/freddyouellette-php-files-normalizer/health.svg)

```
[![Health](https://phpackages.com/badges/freddyouellette-php-files-normalizer/health.svg)](https://phpackages.com/packages/freddyouellette-php-files-normalizer)
```

PHPackages © 2026

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