PHP code example of gmi / toolkit-fileinfo
1. Go to this page and download the library: Download gmi/toolkit-fileinfo library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gmi / toolkit-fileinfo example snippets
use Gmi\Toolkit\Fileinfo\FileInfo;
$fileInfo = new FileInfo('/path/to/awesome.pdf');
/**
* Get information about file path:
* @see Gmi\Toolkit\Fileinfo\Part\PathInfo
*/
$fileInfo->path()->getPath();
// '/path/to'
$fileInfo->path()->getFilename();
// 'awesome.pdf'
$fileInfo->path()->getFilenameWithoutExtension();
// 'awesome'
$fileInfo->path()->getExtension();
// 'pdf'
/**
* Get information about file size:
* @see Gmi\Toolkit\Fileinfo\Part\SizeInfo
*/
$fileInfo->size()->getSize();
// 34703
$fileInfo->size()->getSizeFormatted();
// '33.89 KiB'
/**
* Get information about file dates:
* @see Gmi\Toolkit\Fileinfo\Part\DateInfo
*/
$fileInfo->date()->getLastAccessed();
// object(DateTime)
$fileInfo->date()->getLastModified();
// object(DateTime)
/**
* Get information about file permissions:
* @see Gmi\Toolkit\Fileinfo\Part\PermissionInfo
*/
$fileInfo->perm()->getOwner();
// 0
$fileInfo->perm()->getOwnerName();
// 'root'
$fileInfo->perm()->getPermsFormatted();
// 'rw-r--r--'
/**
* Get information about file type:
* @see Gmi\Toolkit\Fileinfo\Part\TypeInfo
*/
$fileInfo->type()->getMimeType();
// 'application/pdf'
/**
* Reload file information:
*/
$fileInfo->reload();