CKEditor 图片上传
可以做如下配置:
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: filebrowserBrowseUrl
and filebrowserUploadUrl
.
CKEDITOR.replace('editor1',{
In the example above, the
filebrowserBrowseUrl:'/browser/browse.php',
filebrowserImageBrowseUrl:'/browser/browse.php?type=Images',
filebrowserUploadUrl:'/uploader/upload.php',
filebrowserImageUploadUrl:'/uploader/upload.php?type=Images'});filebrowserBrowseUrl
andfilebrowserUploadUrl
settings will be used by default. In the Image Properties dialog window CKEditor will use thefilebrowserImageBrowseUrl
andfilebrowserImageUploadUrl
configuration settings instead.
在image上传中,会使用filebrowserImageUploadUrl; 传递选择的文件:
To send back the file URL from an external file browser, call CKEDITOR.tools.callFunction and passCKEditorFuncNum
as the first argument:
window.opener.CKEDITOR.tools.callFunction( funcNum, fileUrl [, data]);
Ifdata
(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 图片上传的更多相关文章
- springMVC和ckeditor图片上传
springMVC和ckeditor图片上传 http://blog.csdn.net/liuchangqing123/article/details/45270977 修正一下路径问题: packa ...
- 简单2步实现 asp.net mvc ckeditor 图片上传
1.打开ckeditor 包下的 config.js,添加一句 配置(PS:ckeditor 很多功能都在该配置文件里配置),如下: config.filebrowserImageUploadUrl ...
- .net core CKEditor 图片上传
最近在玩 asp.net core,不想用UEditor,想使用CKEditor.故需要图片上传功能. 废话不多说,先上效果图: CKEditor 前端代码: <text id="co ...
- CKEditor图片上传实现详细步骤(使用Struts 2)
本人使用的CKEditor版本是3.6.3.CKEditor配置和部署我就不多说. CKEditor的编辑器工具栏中有一项“图片域”,该工具可以贴上图片地址来在文本编辑器中加入图片,但是没有图片上传. ...
- CKEditor图片上传问题(默认安装情况下编辑器无法处理图片),通过Base64编码字符串解决
准备做一个文章内容网站,网页编辑器采用CKEditor,第一次用,默认安装情况下,图片无法插入,提示没有定义上传适配器(adapter),错误码提示如下: 根据提示,在官网看到有两种途径:一使用CKE ...
- C# MVC 使用 CKEditor图片上传 提示“不正确的服务器响应”
重点:看一下你使用的CKEditor版本 过程: 后台需要一款富文本编辑器.经过挑选后,最后选择了FCKEditor 的升级版 CKEditor .在官网下载了4.10.1版本. 经过一番配置后,富文 ...
- ckeditor图片上传二三事
最近实验室要用ckeditor,踩了几个小坑记录下. 1.出现iframe跨域问题 response.setHeader("X-Frame-Options", "SAME ...
- 使用struts2完成ckeditor和图片上传
代码地址如下:http://www.demodashi.com/demo/12427.html 使用struts2完成ckeditor和ckeditor图片上传 ckeditor版本ckeditor_ ...
- WINDOW.PARENT.CKEDITOR.TOOLS.CALLFUNCTION 图片上传
CKEDITOR 编辑器 图片上传 WINDOW.PARENT.CKEDITOR.TOOLS.CALLFUNCTION (CKEditorFuncNum,图片路径,返回信息); CKEditor ...
随机推荐
- ContentType 属性 MIME
".asf" = "video/x-ms-asf" ".avi" = "video/avi" ".doc&qu ...
- English - 英语中的时间表达法,这里全啦!
- FAT下的winhex数据恢复
一·我在自己的U盘中建一个一个文件abc.word,然后删除 二·用winhex打开需要恢复的磁盘 我这是U盘 I:按确定打开它 三.来到它的根目录下 四·查找文件名,找到文件目录项 文件起始簇号:5 ...
- 《JavaScript+DOM编程艺术》的摘要(五)-----添加insertAfter
在JS原生里面,没有提供insertAfter这个方法,不过我们可以利用appendChild.insertBefore.parentNode这些方法创建一个insertAfter方法,代码如下: f ...
- VS插件
VS插件 背景 前些天去考科目二,感觉经历了一场不是高考却胜似高考的考试(10年前的5分之差, 还是难以释怀)! 一行八人,就我学的时间最少(4天,8人一辆车),教练都觉得我肯定还得再来一次! ...
- 常用CSS HACK
常用CSS HACK IE6 3像素bug和双边距bug一样的经典 现象: IE6下浮动元素和不浮动元素之间会有3px间隙(3px bug,div.float-left + div.float-non ...
- tomcat部署不正确
我把一个名为cp的web项目导入myeclipse中,由于要再次导入该工程的新版本,我就把旧版本的cp项目改名成cp3.但是在运行新项目cp的时候,tomcat出问题,一直是之前旧cp对应的tomca ...
- 64位WINDOWS系统环境下应用软件开发的兼容性问题(CPU 注册表 目录)
应用软件开发的64 位WINDOWS 系统环境兼容性 1. 64 位CPU 硬件 目前的64位CPU分为两类:x64和IA64.x64的全称是x86-64,从名字上也可以看出来它和 x86是兼容的,原 ...
- VM 映像
让我们一起欢呼吧!随着最近Microsoft Azure运行时的发布,我们非常高兴地宣布发布 OS映像的继承性产品:新 VM映像.等一下-有些人可能会觉得这听起来有点耳熟.没错,一个月前在旧金山 ...
- 脑波设备mindwave TGCD接口开发示例
对于TGCD的开发,神念科技提供的文件包括,头文件thinkgear.h,thinkgear.lib,thinkgear.dll,有这三个文件,在win32下开发就不是什么难事了吧 如果是java语言 ...