phpyii2kcfinder

KCFinder for Yii2


I installed KCFinder extension in my yii2 application via composer. In view I using next code:

        use iutbay\yii2kcfinder\KCFinderInputWidget;

        echo KCFinderInputWidget::widget([
            'name' => 'file',
        ]);

Widget works but I can't upload files because there is no 'Upload' button in widget.


Solution

  • Check widget description, https://github.com/iutbay/yii2-kcfinder. You need set option 'access.files.upload' in 'true'.

       $kcfOptions = array_merge(KCFinder::$kcfDefaultOptions, [
            'uploadURL' => Yii::getAlias('@web').'/upload',
            'access' => [
                'files' => [
                    'upload' => true,
                    .......
            ],
        ]);
    
        // Set kcfinder session options
        Yii::$app->session->set('KCFINDER', $kcfOptions);
    

    You should rewrite options after you created widget