This library provides utilities for the file.
...
use Msgframework\Lib\File\File;
$file = new File($path);
...
$file = new File($path);
$allow_extensions = array('jpg', 'png');
if (!in_array($extension = $file->getExtension(), $allow_extensions)) {
throw new \RuntimeException(sprintf('File extension "%s" not allowed, allow: %s', $extension, implode(", ", $allow_extensions)));
}
...
$file = new File($path);
$content = $file->getContent();
You can install this package easily with Composer.
Just require the package with the following command:
$ composer require msgframework/file