我将 Ck finder 与 Ck Editor 集成,但是当我单击浏览按钮时,一个窗口出现在我面前,并显示一条消息:
“出于安全原因,文件浏览器已禁用。请联系您的系统管理员并检查 Ck Finder 配置文件”
我不知道该怎么办
Here:
function CheckAuthentication()
{
return false;
}
默认情况下CheckAuthentication()
,出于安全原因禁用它,因为它允许任何人将文件上传到您的服务器。
出于测试目的,您可以返回true
,但关键是您实现了一些逻辑以仅授权经过身份验证的用户。
function CheckAuthentication()
{
//put some logic here
return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
}
创建包含编辑器的索引文件(index.html),如下代码所示。
<html>
<head>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
</head>
<body>
<h1>CKEditor CKFinder Integration using PHP</h1>
<textarea id="editor1" name="editor1" rows="10" cols="80"></textarea>
<script type="text/javascript">
var editor = CKEDITOR.replace( 'editor1', {
filebrowserBrowseUrl : 'ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?type=Images',
filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?type=Flash',
filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});
CKFinder.setupCKEditor( editor, '../' );
</script>
</body>
</html>
所以你的文件夹结构将是这样的:
文档 |_集成 |_ckeditor | |_config.js | |_... |_ckfinder | |_config.php | |_... |_上传 |_index.html
现在在 ckfinder 中打开文件 config.php 并进行以下更改:
function CheckAuthentication() {
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
// return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
return true; // not good option though; go for sessions
}
$baseUrl = 'http://localhost/integrated/uploads/';
$enabled = true;
$config['SecureImageUploads'] = false;
$config['ChmodFolders'] = 0777 ;
http://localhost/integrated/
并尝试上传图片。