Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 51 | All time: 10,677 This week: 206 |
Version | License | PHP version | Categories | |||
mezon-security 1.0 | MIT/X Consortium ... | 5 | PHP 5, Graphics, Files and Folders, V... |
Description | Author | |
This package can validate uploaded files using multiple rules. |
Mezon provides set of classes wich will help you to validate data from front-end
Just print in console
composer require mezon/security
And that's all )
First of all you need to create validator for the file size:
use \Mezon\Security;
// here we set that file must not be greater then 2KB
$sizeValidator = new Validators\File\Size(2 * Validators\File\Size::KB);
Then you can run validation
$security = new SecurityRules();
$security->isUploadedFileValid('uploaded-file', $validators);
Here 'uploaded-file' is an index in the $_FILES array.
You can validate mime types of the uploading files. To do this construct special validator and pass a list of valid mime types to it's constructor
// here we set that file must not be greater then 2KB
$sizeValidator = new Validators\File\MymeType(['image/png', 'image/jpeg', 'image/jpg']);
And then call isUploadedFileValid like in the example above.
You can use validators for the image size:
new Mezon\Security\Validators\File\ImageMaximumWidthHeight(<maximum width>, <maximum height>);
// and
new Mezon\Security\Validators\File\ImageMinimumWidthHeight(<minimum width>, <minimum height>);
Files (15) |
File | Role | Description | ||
---|---|---|---|---|
Tests (1 file, 1 directory) | ||||
Validators (2 files, 1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation | ||
Security.php | Class | Class source | ||
SecurityRules.php | Class | Class source |
Files (15) | / | Validators |
File | Role | Description | ||
---|---|---|---|---|
File (4 files) | ||||
AbstractValidator.php | Class | Class source | ||
ValidatorInterface.php | Class | Class source |
Files (15) | / | Validators | / | File |
File | Role | Description |
---|---|---|
ImageMaximumWidthHeight.php | Class | Class source |
ImageMinimumWidthHeight.php | Class | Class source |
MimeType.php | Class | Class source |
Size.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.