我正试图建立一个新的CKFinder 3实例(与CKEditor集成),并且正试图追踪并解决这个问题。对不起文字墙。
当我尝试打开“浏览”窗口时(只要打开窗口),我就会得到加载动作并在上传文件夹中生成以下日志(我打开了调试日志)。
[2015-10-19 23:05:41] CKFinder.ERROR: exception 'CKSource\CKFinder\Exception\InvalidResourceTypeException' with message 'Invalid resource type: ' in C:\inetpub\wwwroot\*snip*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Config.php:376
Stack trace:
#0 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\ResourceType\ResourceTypeFactory.php(34): CKSource\CKFinder\Config->getResourceTypeNode('')
#1 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Filesystem\Folder\WorkingFolder.php(96): CKSource\CKFinder\ResourceType\ResourceTypeFactory->getResourceType('')
#2 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(117): CKSource\CKFinder\Filesystem\Folder\WorkingFolder->__construct(Object(CKSource\CKFinder\CKFinder))
#3 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\pimple\pimple\src\Pimple\Container.php(112): CKSource\CKFinder\CKFinder->CKSource\CKFinder\{closure}(Object(CKSource\CKFinder\CKFinder))
#4 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(288): Pimple\Container->offsetGet('working_folder')
#5 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Command\CommandAbstract.php(68): CKSource\CKFinder\CKFinder->getWorkingFolder()
#6 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CommandResolver.php(150): CKSource\CKFinder\Command\CommandAbstract->checkPermissions()
#7 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\symfony\http-kernel\Symfony\Component\HttpKernel\HttpKernel.php(133): CKSource\CKFinder\CommandResolver->getController(Object(Symfony\Component\HttpFoundation\Request))
#8 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\symfony\http-kernel\Symfony\Component\HttpKernel\HttpKernel.php(66): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#9 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(491): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(261): CKSource\CKFinder\CKFinder->handle(Object(Symfony\Component\HttpFoundation\Request))
#11 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\connector.php(20): CKSource\CKFinder\CKFinder->run()
#12 {main} [] []
我用来访问CKFinder的网址是http://*SNIP*/resources/other/ckfinder/ckfinder.html?type=Images
,因此资源类型肯定是根据需要设置的。它也明确存在于配置中,如下所示。
这是尝试使用快速上传工具时记录的异常:
[2015-10-19 23:06:19] CKFinder.ERROR: exception 'CKSource\CKFinder\Exception\UnauthorizedException' with message 'Unauthorized' in C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Command\CommandAbstract.php:75
Stack trace:
#0 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CommandResolver.php(150): CKSource\CKFinder\Command\CommandAbstract->checkPermissions()
#1 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\symfony\http-kernel\Symfony\Component\HttpKernel\HttpKernel.php(133): CKSource\CKFinder\CommandResolver->getController(Object(Symfony\Component\HttpFoundation\Request))
#2 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\symfony\http-kernel\Symfony\Component\HttpKernel\HttpKernel.php(66): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#3 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(491): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#4 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\CKFinder.php(261): CKSource\CKFinder\CKFinder->handle(Object(Symfony\Component\HttpFoundation\Request))
#5 C:\inetpub\wwwroot\*SNIP*\resources\other\ckfinder\core\connector\php\connector.php(20): CKSource\CKFinder\CKFinder->run()
#6 {main} [] []
config.php(NB。$_SESSION['guid']
的一些选定的相关部分是先前设置的,不是问题的原因):
...
$config['authentication'] = function() {
if (isset($_SESSION['guid'])) {
return true;
} else {
return false;
}
};
...
$config['backends'][] = array(
'name' => 'default',
'adapter' => 'local',
'baseUrl' => '/resources/uploads/'.$_SESSION['guid'].'/',
// 'root' => '', // Can be used to explicitly set the CKFinder user files directory.
'chmodFiles' => 0777,
'chmodFolders' => 0755,
'filesystemEncoding' => 'UTF-8',
);
...
$config['defaultResourceTypes'] = '';
$config['resourceTypes'][] = array(
'name' => 'Files', // Single quotes not allowed.
'directory' => 'files',
'maxSize' => 0,
'allowedExtensions' => 'doc,docx,gif,jpeg,jpg,pdf,png,ppt,pptx,xls,xlsx',
'deniedExtensions' => '',
'backend' => 'default'
);
$config['resourceTypes'][] = array(
'name' => 'Images',
'directory' => 'images',
'maxSize' => 0,
'allowedExtensions' => 'gif,jpeg,jpg,png',
'deniedExtensions' => '',
'backend' => 'default'
);
...
$config['accessControl'][] = array(
'role' => '*',
'resourceType' => '*',
'folder' => '/',
'FOLDER_VIEW' => true,
'FOLDER_CREATE' => true,
'FOLDER_RENAME' => true,
'FOLDER_DELETE' => true,
'FILE_VIEW' => true,
'FILE_UPLOAD' => true,
'FILE_RENAME' => true,
'FILE_DELETE' => true,
'IMAGE_RESIZE' => true,
'IMAGE_RESIZE_CUSTOM' => true
);
...
路径设置正确并具有正确的权限。 CKFinder成功创造了''文件夹以及.ckfinder子文件夹。如果使用快速上传工具,它还会创建'图像'或者'文件'子文件夹但不上传任何内容。
快速上传工具会显示未经授权的内容。即使我明确设置$config['authentication'] = true;
。
其他相关信息:
PHP 5.6.7
Windows Server 2012 R2 / IIS 8.5
CKEditor 4.5.3
我已经在这方面绞尽脑汁并试图在过去几周内追踪它,所以任何帮助都会受到赞赏。
答案 0 :(得分:2)
我发现在config.php中明确列出默认资源类型修复了这个问题。我认为这是一个错误,因为documentation表示如果将此字段保留为空字符串,则会加载所有资源类型,但将其保留为空字符串似乎会破坏初始化过程。
例如,在config.php中,替换:
$config['defaultResourceTypes'] = '';
使用:
$config['defaultResourceTypes'] = 'Files,Images';