可以做如下配置:

CKEDITOR.replace('editor1',{
filebrowserBrowseUrl:'/browser/browse.php',
filebrowserUploadUrl:'/uploader/upload.php'});

It is also possible to set a separate URL for a selected dialog window by using the dialog window name in file browser settings: filebrowserBrowseUrland filebrowserUploadUrl.

CKEDITOR.replace('editor1',{
filebrowserBrowseUrl:'/browser/browse.php',
filebrowserImageBrowseUrl:'/browser/browse.php?type=Images',
filebrowserUploadUrl:'/uploader/upload.php',
filebrowserImageUploadUrl:'/uploader/upload.php?type=Images'});
In the example above, the filebrowserBrowseUrl and filebrowserUploadUrl settings will be used by default. In the Image Properties dialog window CKEditor will use the filebrowserImageBrowseUrl and filebrowserImageUploadUrl configuration settings instead.
在image上传中,会使用filebrowserImageUploadUrl; 传递选择的文件:
To send back the file URL from an external file browser, call CKEDITOR.tools.callFunction and pass CKEditorFuncNum as the first argument:
window.opener.CKEDITOR.tools.callFunction( funcNum, fileUrl [, data]);

If data (the third argument) is a string, it will be displayed by CKEditor. This parameter is usually used to display an error message if a problem occurs during the file upload.

The following code shows how to send back the URL of an uploaded file from the PHP connector:
<?php
// Required: anonymous function reference number as explained above.
$funcNum = $_GET['CKEditorFuncNum'] ;
// Optional: instance name (might be used to load a specific configuration file or anything else).
$CKEditor = $_GET['CKEditor'] ;
// Optional: might be used to provide localized messages.
$langCode = $_GET['langCode'] ; // Check the $_FILES array and save the file. Assign the correct path to a variable ($url).
$url = '/path/to/uploaded/file.ext';
// Usually you will only assign something here if the file could not be uploaded.
$message = ; echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
?>

完整的上传图片的代码:

在config设置

filebrowserImageUploadUrl: 'uploadImage.php?type=Images',

uploadImage.php代码如下:

<?php
$url = 'images/uploads/'.time()."_".$_FILES['upload']['name']; /*
$move = @ move_uploaded_file($_FILES['upload']['tmp_name'], $url);
$funcNum = $_GET['CKEditorFuncNum'] ;
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
*/
//extensive suitability check before doing anything with the file...
if (($_FILES['upload'] == "none") ||(empty($_FILES['upload']['name'])) )
{
$message = "No file uploaded.";
}
else if ($_FILES['upload']["size"] == 0)
{
$message = "The file is of zero length.";
}
else if (($_FILES['upload']["type"] != "image/pjpeg") && ($_FILES['upload']["type"] != "image/jpeg") && ($_FILES['upload']["type"] != "image/png")&&($_FILES['upload']["type"] != "image/gif"))
{
$message = "图片格式必须是jpg/gif/png";
}
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 = "";
$move = @ move_uploaded_file($_FILES['upload']['tmp_name'], $url);
if(!$move)
{
$message = "Error moving uploaded file. Check the script is granted Read/Write/Modify permissions.";
}
//$url=$url;
} $funcNum = $_GET['CKEditorFuncNum'] ;
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction($funcNum, '$url', '$message');</script>";
?>

参考:

http://www.caeus.com/articles/how-to-add-and-upload-an-image-using-ckeditor/

http://www.phpzixue.cn/detail847.shtml

http://blog.csdn.net/xiao__gui/article/details/7684505

http://codeigniter.org.cn/forums/thread-13708-1-1.html

CKEditor 图片上传的更多相关文章

  1. springMVC和ckeditor图片上传

    springMVC和ckeditor图片上传 http://blog.csdn.net/liuchangqing123/article/details/45270977 修正一下路径问题: packa ...

  2. 简单2步实现 asp.net mvc ckeditor 图片上传

    1.打开ckeditor 包下的  config.js,添加一句 配置(PS:ckeditor 很多功能都在该配置文件里配置),如下: config.filebrowserImageUploadUrl ...

  3. .net core CKEditor 图片上传

    最近在玩 asp.net core,不想用UEditor,想使用CKEditor.故需要图片上传功能. 废话不多说,先上效果图: CKEditor 前端代码: <text id="co ...

  4. CKEditor图片上传实现详细步骤(使用Struts 2)

    本人使用的CKEditor版本是3.6.3.CKEditor配置和部署我就不多说. CKEditor的编辑器工具栏中有一项“图片域”,该工具可以贴上图片地址来在文本编辑器中加入图片,但是没有图片上传. ...

  5. CKEditor图片上传问题(默认安装情况下编辑器无法处理图片),通过Base64编码字符串解决

    准备做一个文章内容网站,网页编辑器采用CKEditor,第一次用,默认安装情况下,图片无法插入,提示没有定义上传适配器(adapter),错误码提示如下: 根据提示,在官网看到有两种途径:一使用CKE ...

  6. C# MVC 使用 CKEditor图片上传 提示“不正确的服务器响应”

    重点:看一下你使用的CKEditor版本 过程: 后台需要一款富文本编辑器.经过挑选后,最后选择了FCKEditor 的升级版 CKEditor .在官网下载了4.10.1版本. 经过一番配置后,富文 ...

  7. ckeditor图片上传二三事

    最近实验室要用ckeditor,踩了几个小坑记录下. 1.出现iframe跨域问题 response.setHeader("X-Frame-Options", "SAME ...

  8. 使用struts2完成ckeditor和图片上传

    代码地址如下:http://www.demodashi.com/demo/12427.html 使用struts2完成ckeditor和ckeditor图片上传 ckeditor版本ckeditor_ ...

  9. WINDOW.PARENT.CKEDITOR.TOOLS.CALLFUNCTION 图片上传

    CKEDITOR  编辑器   图片上传 WINDOW.PARENT.CKEDITOR.TOOLS.CALLFUNCTION (CKEditorFuncNum,图片路径,返回信息); CKEditor ...

随机推荐

  1. linux查看与开启ssh

    首先通过物理终端进入到linux上,手工检查ssh发现没运行/etc/init.d/sshd statussshd is stopped手工启动服务,发现报告权限错误./etc/init.d/sshd ...

  2. c++ 11 vs 98

    在求最长子字符串中题中要遍历个上万字符数据 1.使用c++11代码 for (auto ch : s) { auto ss = vsi[ch]; vsi[ch].insert(i); i++; } 2 ...

  3. leetcode Contains Duplicate python

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  4. Java 遍历文件下jpg图片并解析图片

      package filetest; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; ...

  5. codevs 1256 打鼹鼠 LIS

    题目链接 题目描述 Description 鼹鼠是一种很喜欢挖洞的动物,但每过一定的时间,它还是喜欢把头探出到地面上来透透气的. 根据这个特点阿Q编写了一个打鼹鼠的游戏:在一个n*n的网格中,在某些时 ...

  6. PCB成型製程介紹

    PCB成型製程在電子構裝中所扮演的角色 下圖是電腦主機的內部組成 我們將以插在主機板上的一片 USB擴充卡來說明PCB成型製 程在電子構裝中所扮演的角色 PCB成型製程的子製程 USB擴充卡要插入主機 ...

  7. POJ 3581 Sequence(后缀数组)

    [题目链接] http://poj.org/problem?id=3581 [题目大意] 给出一个数列,将这个数列分成三段,每段分别翻转,使得其字典序最小,输出翻转后的数列. [题解] 首先,第一个翻 ...

  8. delphi ICS控件示例解读

    {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Author: Fran鏾is PIETTE ...

  9. Michael Kors成了时尚行业的公敌-股票频道-和讯网

    Michael Kors成了时尚行业的公敌-股票频道-和讯网 Michael Kors成了时尚行业的公敌 字号   评论 邮件 纠错 2014年03月03日17:32 来源:财经天下    全球消费不 ...

  10. 1分钟搞定超慢SQL

    前几天,一个用户的研发人员找到我了,说他们有个SQL语句非常慢,我说多慢?他们说:半个小时也没出结果.于是问他们要了SQL语句和执行计划,SQL语句就不能再这里贴出来了,下面是调整前的执行计划(略去某 ...