PHP code example of xi / filelib
1. Go to this page and download the library: Download xi/filelib 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/ */
xi / filelib example snippets
use Xi\Filelib\FileLibrary;
use Xi\Filelib\Backend\Adapter\JsonBackendAdapter;
use Xi\Filelib\Storage\Adapter\FilesystemStorageAdapter;
use Pekkis\DirectoryCalculator\DirectoryCalculator;
use Pekkis\DirectoryCalculator\Strategy\UniversalLeveledStrategy;
$filelib = new FileLibrary(
new FilesystemStorageAdapter(
__DIR__ . '/files',
new DirectoryCalculator(new UniversalLeveledStrategy()
),
new JsonBackendAdapter(__DIR__ . '/filelib-example.json')
);
$file = $filelib->uploadFile('/path/to/some/file.jpg');
// Display the image
header("Content-Type: " . $file->getMimetype());
echo file_get_contents($filelib->getStorage()->retrieve($file->getResource()));