Download the PHP package freddyouellette/php-files-normalizer without Composer
On this page you can find all versions of the php package freddyouellette/php-files-normalizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download freddyouellette/php-files-normalizer
More information about freddyouellette/php-files-normalizer
Files in freddyouellette/php-files-normalizer
Package php-files-normalizer
Short Description Normalizes the PHP $_FILES array to a friendlier format.
License MIT
Informations about the package php-files-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:
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:
Things to consider:
- The normalizer will treat all file inputs as if they were
multiple. That means that the finalfileslayer will always be an array of files, even if only one file was POSTed. - Don't forget to add the
multipleattribute and[]to the end of your input name when you want multiple files.
Usage
Install via composer:
and in your php file:
If you would rather merge the $_FILES array into an existing one, just pass the existing array as the second argument:
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.
Contributing
I encourage all issues to be submitted through the Issues tab on GitHub. Pull requests are welcome.