Search code examples
javascriptphpckfinder

Subfolders are created in all resourceTypes in CkFinder


Using CkFinder V3 in file config.php have setup different resourceTypes.

The settings works and I get in CkFinder on the left panel two "entries" called "My Images" and "My Videos".

Now when I select folder "My Videos" and create a sub folder, the sub folder is being added on "My Videos" and also on "My Images".

I need to add a sub folder only in the place where user decided too.

What is wrong in my configurations?

$config['resourceTypes'][] = array(
    'name'              => 'Images',
    'label'             => 'My Images',
    'maxSize'           => '2M',
    'allowedExtensions' => 'gif,jpeg,jpg,png',
    'deniedExtensions'  => '',
    'backend'           => 'default'
);

$config['resourceTypes'][] = array(
    'name'              => 'Videos',
    'label'             => 'My Videos',
    'maxSize'           => '1G',
    'allowedExtensions' => 'mp4',
    'deniedExtensions'  => '',
    'backend'           => 'default'
);

Solution

  • Both resource types you have defined point to the same folder (the root folder of the default backend), because they do not define a directory. To use separate folders please use the directory option, like presented below:

    $config['resourceTypes'][] = array(
        'name'              => 'Images',
        'label'             => 'My Images',
        'maxSize'           => '2M',
        'allowedExtensions' => 'gif,jpeg,jpg,png',
        'deniedExtensions'  => '',
        'directory'         => 'images', // ←
        'backend'           => 'default'
    );
    
    $config['resourceTypes'][] = array(
        'name'              => 'Videos',
        'label'             => 'My Videos',
        'maxSize'           => '1G',
        'allowedExtensions' => 'mp4',
        'deniedExtensions'  => '',
        'directory'         => 'videos', // ←
        'backend'           => 'default'
    );