1. Go to this page and download the library: Download ngscz/nette-elfinder 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/ */
ngscz / nette-elfinder example snippets
namespace App\Presenters;
use Nette;
class ElfinderPresenter extends Nette\Application\UI\Presenter
{
use \Ngscz\Elfinder\Presenters\ElfinderPresenter;
public function renderDefault()
{
$template = $this->getTemplate();
$template->SEPARATOR .
'Elfinder' . DIRECTORY_SEPARATOR .
'default.latte';
}
}
namespace App\Presenters;
use Nette\Application\UI;
use Ngscz\Elfinder\Forms\ElfinderInput;
class HomepagePresenter extends FrontendPresenter
{
protected function createComponentForm()
{
$form = new UI\Form;
$form->addComponent(new ElfinderInput, 'file');
$form->addSubmit('submit');
// how to set default values
$qb = $this->assetTable->prepareQueryBuilder();
$files = [];
foreach ($qb->getQuery()->getResult() as $file) {
$files[] = [
'hash' => $file->getHash(),
'url' => '/uploads' . $file->getPath(),
];
}
$form->setDefaults([
'file' => $files,
]);
$form->onSuccess[] = function($form, $values) {
dumpe($values);
//will return array of hashe
};
return $form;
}
}