问题描述
我的网站使用 CKEditor 5 和 CKFinder,我将 baseUrl 更改为 http://localhost/ckeditor/assets/ckfinder/userfiles/。我测试上传文件,它工作得很好,当我上传图片时,它给了我未知的错误。在开发者工具网络选项卡中,我得到以下响应
{"resourceType":"Images","currentFolder":{"path":"\/","acl":1023,"url":"http:\/\/localhost\/ckeditor\/assets\/ckfinder\/userfiles\/images\/"},"error":{"number":110,"message":"UnkNown error."}}
谁能帮帮我
<pre>
<?PHP
/*
* CKFinder Configuration File
*
* For the official documentation visit https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/
*/
/*============================ PHP Error Reporting ====================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/debugging.html
// Production
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
ini_set('display_errors',0);
// Development
// error_reporting(E_ALL);
// ini_set('display_errors',1);
/*============================ General Settings =======================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html
$config = array();
/*============================ Enable PHP Connector HERE ==============================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_authentication
$config['authentication'] = function () {
return true;
};
/*============================ License Key ============================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_licenseKey
$config['licenseName'] = '';
$config['licenseKey'] = '';
/*============================ CKFinder Internal Directory ============================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_privateDir
$config['privateDir'] = array(
'backend' => 'default','tags' => '.ckfinder/tags','logs' => '.ckfinder/logs','cache' => '.ckfinder/cache','thumbs' => '.ckfinder/cache/thumbs',);
/*============================ Images and Thumbnails ==================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_images
$config['images'] = array(
'maxWidth' => 1600,'maxHeight' => 1200,'quality' => 80,'sizes' => array(
'small' => array('width' => 480,'height' => 320,'quality' => 80),'medium' => array('width' => 600,'height' => 480,'large' => array('width' => 800,'height' => 600,'quality' => 80)
)
);
/*=================================== Backends ========================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_backends
$config['backends'][] = array(
'name' => 'default','adapter' => 'local','baseUrl' => 'http://localhost/ckeditor/assets/ckfinder/userfiles/',// 'root' => '',// Can be used to explicitly set the CKFinder user files directory.
'chmodFiles' => 0777,'chmodFolders' => 0755,'filesystemEncoding' => 'UTF-8',);
/*================================ Resource Types =====================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_resourceTypes
$config['defaultResourceTypes'] = '';
$config['resourceTypes'][] = array(
'name' => 'Files',// Single quotes not allowed.
'directory' => 'files','maxSize' => 0,'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip','deniedExtensions' => '','backend' => 'default'
);
$config['resourceTypes'][] = array(
'name' => 'Images','directory' => 'images','allowedExtensions' => 'bmp,png','backend' => 'default'
);
/*================================ Access Control =====================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_roleSessionVar
$config['roleSessionVar'] = 'CKFinder_UserRole';
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_accessControl
$config['accessControl'][] = array(
'role' => '*','resourceType' => '*','folder' => '/','FOLDER_VIEW' => true,'FOLDER_CREATE' => true,'FOLDER_RENAME' => true,'FOLDER_DELETE' => true,'FILE_VIEW' => true,'FILE_CREATE' => true,'FILE_RENAME' => true,'FILE_DELETE' => true,'IMAGE_RESIZE' => true,'IMAGE_RESIZE_CUSTOM' => true
);
/*================================ Other Settings =====================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html
$config['overwriteOnUpload'] = false;
$config['checkDoubleExtension'] = true;
$config['disallowUnsafeCharacters'] = false;
$config['secureImageUploads'] = true;
$config['checkSizeAfterScaling'] = true;
$config['htmlExtensions'] = array('html','htm','xml','js');
$config['hideFolders'] = array('.*','CVS','__thumbs');
$config['hideFiles'] = array('.*');
$config['forceAscii'] = false;
$config['xSendfile'] = false;
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_debug
$config['debug'] = false;
/*==================================== Plugins ========================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_plugins
$config['pluginsDirectory'] = __DIR__ . '/plugins';
$config['plugins'] = array();
/*================================ Cache settings =====================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_cache
$config['cache'] = array(
'imagePreview' => 24 * 3600,'thumbnails' => 24 * 3600 * 365,'proxyCommand' => 0
);
/*============================ Temp Directory settings ================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_tempDirectory
$config['tempDirectory'] = sys_get_temp_dir();
/*============================ Session Cause Performance Issues =======================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_sessionWriteClose
$config['sessionWriteClose'] = true;
/*================================= CSRF protection ===================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_csrfProtection
$config['csrfProtection'] = true;
/*===================================== Headers =======================================*/
// https://ckeditor.com/docs/ckfinder/ckfinder3-PHP/configuration.html#configuration_options_headers
$config['headers'] = array();
/*============================== End of Configuration =================================*/
// Config must be returned - do not change it.
return $config;
</pre>
我的 index.PHP
包含 textarea、ckeditor 和 ckfinder 的脚本
解决方法
我认为这不是一条正确的道路:
'baseUrl' => 'http://localhost/ckeditor/assets/ckfinder/userfiles/',
我遇到了类似的问题,并通过更改我的配置中的路径来解决它:
'baseUrl' => '/ckfinder/userfiles/'
致:
'baseUrl' => 'http://myDomain.online/ckfinder/userfiles/',
哪个有效。