0
votes

quick question that has been bugging me for days now. I just installed CKfinder and "browsing" works perfect. Except when I want to upload a image or file, it gives me the following error:

Fatal error: Uncaught exception 'ErrorException' with message 'fopen(/home/xxx/app/userfiles/images/sdfdsf.jpg): failed to open stream: Permission denied' in /home/xxx/app/webroot/js/packages/finder/core/connector/php/vendor/league/flysystem/src/Adapter/Local.php:142

I used the following settings:

$config['backends'][] = array(
    'name'         => 'default',
    'adapter'      => 'local',
    'baseUrl'      => '/app/userfiles/',
    'chmodFiles'   => 0777,
    'chmodFolders' => 0755,
    'filesystemEncoding' => 'UTF-8',
);

$config['backends'][] = array(
    'name'         => 'ftp',
    'adapter'      => 'ftp',
    'host'         => 'xxx',
    'username'     => 'xxx',
    'password'     => 'xxx'
);

$config['resourceTypes'] = array(
    array(
        'name'              => 'Files',
        'directory'         => '/home/websites/www/shared/images/ckfinder/',
        'maxSize'           => 0,
        'allowedExtensions' => 'pdf,doc,zip',
        'backend'           => 'ftp',
        'lazyLoad'          => true
    ),
    array(
        'name'              => 'Images',
        'directory'         => '/home/websites/www/shared/images/ckfinder/',
        'maxSize'           => 0,
        'allowedExtensions' => 'gif,jpeg,jpg,png',
        'backend'           => 'ftp',
        'lazyLoad'          => true
    )
 );

As said, browsing images that are located in /app/userfiles/ are working perfect. It even returns the name to my input field.

But at the moment I want to upload a image or file I get this error. Anyone who can tell me how to fix this issue?

P.S. The folders have CHMOD 777 so that should be fine. It seems like the error says that it is trying to upload the file, or access it from the wrong directory e.g. my settings are wrong :)

This was just a test but the local resource will be removed, image/file browsing should be from the FTP only, same as the upload directory that is :)

1

1 Answers

0
votes

Looks like you tried to define absolute paths for resource types. The path used in directory option of the resource type should be relative to the root of the used backend.

Please have a look at following places in the PHP connector docs:

You can use the absolute path to define the backend root, and then use paths relative to the defined root in resource types directory options. For example:

$config['backends'][] = array(
    'name'         => 'ftp',
    'adapter'      => 'ftp',
    'host'         => 'xxx',
    'username'     => 'xxx',
    'password'     => 'xxx',
    'root'         => '/home/websites/www/shared/images/ckfinder/'
);

$config['resourceTypes'] = array(
    array(
        'name'              => 'Images',
        //'directory'         => '', You can also omit this option - the resource type in this case will be attached to the backend root
        'maxSize'           => 0,
        'allowedExtensions' => 'gif,jpeg,jpg,png',
        'backend'           => 'ftp',
        'lazyLoad'          => true
    )
 );