1. Go to this page and download the library: Download atk4/filestore 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/ */
atk4 / filestore example snippets
// in Friend::init();
$this->addField('photo_file_token', [\Atk4\Filestore\Field\FileField::class]);
php
$this->addField('photo_file_token', [
\Atk4\Filestore\Field\FileField::class,
// specify if you want to only accept certain types of files or extensions.
'onlyTypes' => ['image/*', 'application/x-pdf'],
'onlyExtensions' => ['img', 'png', 'pdf'], // safer to specify both
// where to store
'flysystem' => $flysystem,
// you can also define callback if you wish to do something more with the file
'onUpload' => function ($file) {
// do something with file
},
// this is called when form with the file is submitted
'onAttach' => function ($file) {
// $file is a model object
},
// when user detaches file from the related entity
'onDetach' => function ($file) {
// $file is a model object
},
])