CKFinder 无法上传图像,导致错误无法打开流:权限被拒绝


CKFinder cannot upload images, causing error failed to open stream: Permission denied

快速的问题,这个问题已经困扰了我好几天了。我刚刚安装了 CKfinder,"浏览"效果很好。除非我想上传图像或文件,否则它会给我以下错误:

致命错误:未捕获的异常"错误异常"带有消息 'fopen(/home/xxx/app/userfiles/images/sdfdsf.jpg(: 无法打开 流:权限被拒绝' 在 /home/xxx/app/webroot/js/packages/finder/core/connector/php/vendor/league/flysystem/src/Adapter/Local.php:142

我使用了以下设置:

$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
    )
 );

如前所述,浏览位于/app/userfiles/中的图像运行良好。它甚至将名称返回到我的输入字段。

但是目前我想上传图像或文件,我收到此错误。任何人都可以告诉我如何解决此问题?

附言文件夹具有CHMOD 777,因此应该没问题。似乎错误说它正在尝试上传文件,或从错误的目录访问它,例如我的设置错误:)

这只是一个测试,但本地资源将被删除,图像/文件浏览应仅来自FTP,与:)的上传目录相同

看起来您尝试为资源类型定义绝对路径。资源类型的directory选项中使用的路径应相对于所用后端的root

请查看 PHP 连接器文档中的以下位置:

  • http://docs.cksource.com/ckfinder3-php/upgrading.html#upgrading_2to3_resource_types
  • http://docs.cksource.com/ckfinder3-php/howto.html#howto_resource_type_folder

您可以使用绝对路径来定义后端root,然后在资源类型directory选项中使用相对于定义的根的路径。例如:

$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
    )
 );