thai6070
thai6070

Reputation: 31

Use ckfinder in laravel 5.2

Here is my code in config.php:

$path = '/laravel/';
require _DIR_.'/../../../../bootstrap/autoload.php';
$app = require_once _DIR_.'/../../../../bootstrap/app.php';

$app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
$_user = (Auth::check()) ? Auth::user()->username : '';
define('CKFINDER_ROOT_FOLDER', $path.'resources/assets/uploads/'  . $_user .'/');
$config['authentication'] = function () {          
return Auth::check();
};

It works well but I can't upload file (Upload finished with errors). If I remove ->handle(Illuminate\Http\Request::capture() for test, it would run perfectly in this session (not refresh page). Where is my problem. Please help.

Upvotes: 1

Views: 844

Answers (1)

Abhishek
Abhishek

Reputation: 1561

Issue looks with permission that you need to set 0777 on CKFINDER_ROOT_FOLDER

You may need to add this namespace --

use Illuminate\Support\Facades\File;


$path = '/laravel/';
require _DIR_.'/../../../../bootstrap/autoload.php';
    $app = require_once _DIR_.'/../../../../bootstrap/app.php';

    $app->make('Illuminate\Contracts\Http\Kernel')->handle(Illuminate\Http\Request::capture());
    $_user = (Auth::check()) ? Auth::user()->username : '';

    define('CKFINDER_ROOT_FOLDER', $path.'resources/assets/uploads/'  . $_user);

    if(!File::exists($filePath)) {
        File::makeDirectory(CKFINDER_ROOT_FOLDER, $mode = 0777, true,true);
    }

    $config['authentication'] = function () {          
    return Auth::check();
};

Upvotes: 1

Related Questions