![](/img/trans.png)
[英]Ckeditor image upload working, but saying it doesn't (using ckfinder)
[英]CKFinder 3 can't upload files
我對CKFinder 3的實現有問題。除了上傳文件和圖像外,一切正常。
當我點擊上傳。 我在我的電腦上選擇了一個文件然后它給我一個錯誤消息:上傳已完成但有錯誤。 當我點擊詳細信息時,它顯示:無效文件。
在我的調試文件中,它輸出:
[02-Sep-2015 16:35:27 Europe/Berlin] PHP Notice: Undefined index: dirname in ckfinder/core/connector/php/vendor/cksource/ckfinder/src/CKSource/CKFinder/Filesystem/File/UploadedFile.php on line 70
有人可以幫我這個嗎?
這是我的CKFinder的config.php代碼:
<?php
/*
* CKFinder Configuration File
*
* For the official documentation visit http://docs.cksource.com/ckfinder3-php/
*/
/*============================ PHP Error Reporting ====================================*/
// http://docs.cksource.com/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 =======================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html
$config = array();
/*============================ Enable PHP Connector HERE ==============================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_authentication
$config['authentication'] = function() {
return true;
};
/*============================ License Key ============================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_licenseKey
$config['licenseName'] = '';
$config['licenseKey'] = '';
/*============================ CKFinder Internal Directory ============================*/
// http://docs.cksource.com/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 ==================================*/
// http://docs.cksource.com/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, 'quality' => 80),
'large' => array('width' => 800, 'height' => 600, 'quality' => 80)
)
);
/*=================================== Backends ========================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_backends
$config['backends'][] = array(
'name' => 'default',
'adapter' => 'local',
'baseUrl' => '/VVBBC/assets/img/uploads/',
// 'root' => '', // Can be used to explicitly set the CKFinder user files directory.
// 'chmodFiles' => 0777,
// 'chmodFolders' => 0755,
// 'filesystemEncoding' => 'UTF-8',
);
/*================================ Resource Types =====================================*/
// http://docs.cksource.com/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,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,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',
'maxSize' => 0,
'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
'deniedExtensions' => '',
'backend' => 'default'
);
/*================================ Access Control =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_roleSessionVar
$config['roleSessionVar'] = 'CKFinder_UserRole';
// http://docs.cksource.com/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_UPLOAD' => true,
'FILE_RENAME' => true,
'FILE_DELETE' => true,
'IMAGE_RESIZE' => true,
'IMAGE_RESIZE_CUSTOM' => true
);
/*================================ Other Settings =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html
$config['overwriteOnUpload'] = false;
$config['checkDoubleExtension'] = true;
$config['disallowUnsafeCharacters'] = false;
$config['secureImageUploads'] = false;
$config['checkSizeAfterScaling'] = true;
$config['htmlExtensions'] = array('html', 'htm', 'xml', 'js');
$config['hideFolders'] = array('.*', 'CVS', '__thumbs');
$config['hideFiles'] = array('.*');
$config['forceAscii'] = false;
$config['xSendfile'] = false;
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_debug
$config['debug'] = false;
/*==================================== Plugins ========================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_plugins
$config['pluginsDirectory'] = __DIR__ . '/plugins';
$config['plugins'] = array();
/*================================ Cache settings =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_cache
$config['cache'] = array(
'imagePreview' => 24 * 3600,
'thumbnails' => 24 * 3600 * 365
);
/*============================== End of Configuration =================================*/
// Config must be returned - do not change it.
return $config;
我能夠在OSX上重現這個問題。 在此版本的XAMPP中訪問預配置的臨時目錄時出現問題。 這可以通過改變sys_temp_dir
在指令php.ini
,但可以在CKFinder的新版本還配置。
請嘗試以下方法:
config.php
)並在文件底部查找tempDirectory
選項。 sys_get_temp_dir()
替換為您的XAMPP temp
目錄路徑。 對我來說是/Applications/XAMPP/xamppfiles/temp/
。 所以與其:
$config['tempDirectory'] = sys_get_temp_dir();
應該有:
$config['tempDirectory'] = '/Applications/XAMPP/xamppfiles/temp/';
配置其他所需的CKFinder選項,例如身份驗證。 上傳應該現在正常。
另一種方案:
您可以在php.ini
設置全局sys_temp_dir
指令,而不是像上面描述的那樣在應用程序級別上更改它。 為此,請在/Applications/XAMPP/xamppfiles/etc/php.ini
中添加以下行:
sys_temp_dir = "/Applications/XAMPP/xamppfiles/temp/"
然后在XAMPP中重啟Apache。 之后,可以使用sys_get_temp_dir()
獲取臨時目錄位置,因此無需在CKFinder配置中更改tempDirectory
選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.