Wallogit.com
2017 © Pedro Peláez
Get file information from local and also remote file(mime type, extension, file name ...).
Get easily file information from local and also remote file (mime, extension, file name ...), (*1)
composer require vincoweb/easy-php-file-info=dev-master
$finfo = new \VincoWeb\FileInfo\FileInfo(); $i = $finfo->get($file_link [, bool $return_object = false ]);
Variable "$file_link" can contains path and also URL. Variable "$return_object" is optional. Set to true for return object instead of array., (*2)
add provider and alias in config/app.php, (*3)
'providers' => [
...
VincoWeb\FileInfo\FileInfoServiceProvider::class
]
...
'aliases' => [
...
'FileInfo' => VincoWeb\FileInfo\FileInfoFacade::class,
],
and in laravel you use it, (*4)
FileInfo::get($file_link [, bool $return_object = false ]);
<?php
require __DIR__ . '/../vendor/autoload.php';
$finfo = new \VincoWeb\FileInfo\FileInfo();
$i = $finfo->get('https://www.google.sk/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png');
Array ( [link] => https://www.google.sk/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png [mime] => image/png [size] => 13504 [last_modified] => Fri, 04 Sep 2015 22:33:08 GMT [etag] => [extension] => png [type] => image [location] => url [width] => 544 [height] => 3 )
Result returns array with these keys: * link - where file was finded (if there was redirection, it contains reditected location) * location - location of $file_link ( return string "URL" or "path") * mime - mime type (only from header, if $link is URL). * size - file size (if is taken from header, it can contain value "-1") * last_modified - date of last modified * etag - file header etag from ULR (can be empty) or md5 hash of file from path * basename - basename, name of file * extension - file extension got from header(if file is image, it contains real extension ) * type - mime type or string "image" if file is normal image * [width] - width dimension, this key exists only if file is image * [height] - height dimension, this key exists only if file is image, (*5)
It can return boolean false (i.e. if file not exist)., (*6)
IF YOU WANT NEW FEATURES WRITE NEW ISSUE PLS :), (*7)
Unlicense. You can do what you want. Be free!, (*8)