PHP code example of martinmuzatko / filehandler

1. Go to this page and download the library: Download martinmuzatko/filehandler 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/ */

    

martinmuzatko / filehandler example snippets


use martinmuzatko\filehandler\File;
use martinmuzatko\filehandler\Handler as FileHandler;

$file = 'path/to/image.jpg';
$info = FileHandler::getInfo($file);
if ($info->width > 1920 || $info->height > 1080)
{
  echo 'File '.$info->basename.' is too big, resize it to 1920x1080'; 
}

$customers = ['01-jake', '02-mike', '03-francis', '04-martin', '05-jane'];
foreach ($customers as $customer)
{
	$file = new File($customer.'/info.json');
	$file
		->create()
		->write('[{ title: "Read instructions."}]')
		->chmod(0644);
}
 
$info = FileHandler::getInfo($file); echo $info->writable;

$f = new File('index.php'); $f->writable; 

$f = new File('index.php');
$f->move('path/to/new/');

php composer.phar 
fopen()
$file = new File(); $file->find(); $file->selection;
$file->getSelected()

$file->select('file.png');
$file->select(['file.png', 'another.jpg', 'file.avi']);
$file->select([['file.png', 'another.jpg'], 'file.avi']);
$file->select([$file->find(), 'customers/file.txt']);

$file->select($file);