CKFinder无法上传图片

时间:2012-06-11 14:41:52

标签: ckeditor codeigniter-2 ckfinder

我正在尝试将CKFinder与CKEditor集成到CodeIgniter应用程序中,当你使用它时看起来一切正常,但是当我转到该文件夹​​时(默认的/ ckfinder / userfiles仍然在配置中设置) .php文件)那里没有文件。

奇怪的是,如果我点击CKFinder对话框中的“浏览服务器”按钮,我确实看到了我“上传”的图像,但我不知道它们在物理上的位置,因为它们不在指定的位置文件夹中。

以下是我的设置:

$(document).ready(function () {

    var config = {

        toolbar:[
            ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Undo', 'Redo', '-', 'SelectAll', 'Format'],
            ['UIColor'],
            ['Image', '-', 'Link', 'Source']
        ],

        filebrowserBrowseUrl:base_url + '/ckfinder/ckfinder.html',
        filebrowserImageBrowseUrl:base_url + '/ckfinder/ckfinder.html?Type=Images',
        filebrowserFlashBrowseUrl:base_url + '/ckfinder/ckfinder.html?Type=Flash',
        filebrowserUploadUrl:base_url + '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        filebrowserImageUploadUrl:base_url + '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        filebrowserFlashUploadUrl:base_url + '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'



    };
    config.format_tags = 'p;h2;h3;div'
    $('textarea.editor').ckeditor(config);


});

同样,在查找器打开并允许您选择文件等的情况下,一切正常,但文件只是没有显示在文件夹中。

知道我做错了吗?

1 个答案:

答案 0 :(得分:2)

我在代码中没有看到上传功能

我粘贴了我的代码,工作正常。

对于name ='description'和id ='description'

的textarea

在我看来:

<script type='text/javascript'>

$(document).ready(function(){

    CKEDITOR.replace( 'description', {filebrowserUploadUrl : "/admin/ckeditor/"});

    $('#submit').click(function() {

        CKEDITOR.instances.description.updateElement();

        return true;

    });

});

</script>

在我的管理员控制器中,我有上传功能

public function ckeditor()
{
    $url = FCPATH.'public/uploads/ckeditor/'.time()."_".$_FILES['upload']['name'];

    $url_aux = substr($url, strlen(FCPATH) - 1);

    if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])) )
    {
       $message = "No file uploaded.";
    }
    else if(file_exists(FCPATH.'public/uploads/ckeditor/'.$_FILES['upload']['name']))
    {
        $message = "File already exists";
    }
    else if ($_FILES['upload']["size"] == 0)
    {
       $message = "The file is of zero length.";
    }
    else if (($_FILES['upload']["type"] != "image/pjpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png"))
    {
       $message = "The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.";
    }
    else if (!is_uploaded_file($_FILES['upload']["tmp_name"]))
    {
       $message = "You may be attempting to hack our server. We're on to you; expect a knock on the door sometime soon.";
    }
    else 
    {
       $message = "Image uploaded correctly";

       move_uploaded_file($_FILES['upload']['tmp_name'], $url);
    }


    $funcNum = $_GET['CKEditorFuncNum'] ;
    $url = $url_aux;
    echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";

}