1. Go to this page and download the library: Download themusicdev/files 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/ */
'authCallable' => static function ($file): void {
$identity = \Cake\Routing\Router::getRequest()?->getSession()->read('Auth.id');
if ($identity === null) {
throw new \Cake\Http\Exception\RedirectException(
\Cake\Routing\Router::url(['plugin' => false, 'controller' => 'Users', 'action' => 'login']),
);
}
},
use TheMusicDev\Files\Lib\FileStore;
$store = FileStore::instance();
$row = $store->put($request->getUploadedFile('file'), 'contracts.pdf'); // throws FileStoreException on any intake failure
$id = $row->get('id'); // keep this as <your_table>.file_id
$store->get($id); // active row, or FileStoreException
$store->read($row); // contents (bounded by the collection size cap)
$store->delete($row); // soft delete: row trashed, file kept
$store->purge($row); // hard delete: row and file
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.