1. Go to this page and download the library: Download bushbaby/flysystem 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/ */
$sourceFilesystem = $serviceLocator->get(\BsbFlysystem\Service\FilesystemManager::class)->get('default'); // local adapter ./data
$targetFilesystem = $serviceLocator->get(\BsbFlysystem\Service\FilesystemManager::class)->get('archive'); // eg. zip archive
$manager = new League\Flysystem\MountManager(array(
'source' => $sourceFilesystem,
'target' => $targetFilesystem,
));
$contents = $manager->listContents('source://some_directory', true);
foreach ($contents as $entry) {
$manager->write('target://'.$entry->path(), $manager->read('source://'.$entry->path()));
}
$request = new Request();
$files = $request->getFiles();
// i.e. $files['my-upload']['tmp_name'] === '/tmp/php5Wx0aJ'
// i.e. $files['my-upload']['name'] === 'myfile.txt'
// get a filesystem from the BsbFlysystemManager (or construct one manually)
$filesystem = $serviceLocator->get(\BsbFlysystem\Service\FilesystemManager::class)->get('default');
$filter = new \BsbFlysystem\Filter\File\RenameUpload([
'target' => 'path/to/file.txt',
'filesystem' => $filesystem
]);
$filter->filter($files['my-upload']);
// or
$filter->filter('path/to/local/file.txt');
// File has been renamed and moved through $filesystem with key 'path/to/file.txt'