PHP code example of jamieynonan / file-management

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

    

jamieynonan / file-management example snippets


use FileManagement\File;


$imgLocal = new File(__DIR__ .'/file.jpg'); //file
$imgUrl = new File('http://site.com/files/image.png'); //link

//return bool
$imgLocal->validateMime('image/jpeg');
$imgUrl->validateMime('image/png');

first set the path to save the file
$imgLocal->setPath(__DIR__ . '/files');
$imgUrl->setPath('/path/local/where/save/file');

$imgLocal->save();
$imgUrl->save('new-name'); //save and change name

//return new instance of File
$newImage = $imgLocal->copy('/same/path', 'new-name'); //copy with another name
$newImage2 = $newImage->copy('/new/path2'); //copy in another folder with the same name

$newImage2->move('/other/path'); //return bool

$newImage2->rename('new-name-file'); //return bool