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: filebrowserBrowseUrland 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'});filebrowserBrowseUrlandfilebrowserUploadUrlsettings will be used by default. In the Image Properties dialog window CKEditor will use thefilebrowserImageBrowseUrlandfilebrowserImageUploadUrlconfiguration settings instead.
在image上传中,会使用filebrowserImageUploadUrl; 传递选择的文件:
To send back the file URL from an external file browser, call CKEDITOR.tools.callFunction and passCKEditorFuncNumas 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 ...
随机推荐
- JavaScript之怎样获取元素节点
JavaScript获取元素节点一共有三种方法,分别是通过元素ID.通过标签名字和通过类名字来获取: 1.通过元素ID属性的ID值来获得元素对象-getElementById() DOM提供了一个名为 ...
- 前自加(++a)与后自加(a++)的差别
自加是自己加1的操作.比如a++ 是a+1 ,变量a变成了 a+1的值. 如果是简单的只做 a++:或者++a的语句,效果是一样的. 但是如果嵌入到复杂的语句中,比如 b = a++: 和 b = + ...
- Java 动态代理(转)
一.代理模式 代理模式是常用的java设计模式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息.过滤消息.把消息转发给委托类,以及事后 处理消息等.代理类与委托类之间通常会存在 ...
- Composer Yii2 不设置全局变量 归档安装 Win7
1.下载Composer_installer.phar https://getcomposer.org/composer.phar 重命名为 composer_installer.phar 将文件放 ...
- SQL Server 通配符为目标字符的查找
create table t(x int identity(1,1) primary key,v nvarchar(32));go insert into t(v) values('this is % ...
- PADS LAYOUT到底怎么走线
PADS LAYOUT走线,是不是转角要自己手动慢慢转角啊?不能像PROTEL中那样自动转角吗 自己手动转角老是转不好,出现许多线头,对不齐,是不是我操作有误啊 走线的过程中,可以试试这个,切换端点. ...
- 终于懂了:两个UI组件同时在操作是不可能实现的
// 目的:从某个对话框里,选择一些路径,然后用Tree自动展开这些路径,但至少需要几秒钟时间 // 问题:在这几秒钟期间,显示一个等待对话框,只能开多线程,因为后台继续要处理tree的一些事情.等待 ...
- firefox的window.onerror没有详细的出错提示
当在firefox浏览器的a.htm页面中使用script标签加载某a.js出错时,如果放置window.onerror事件处理方法时,此方法获取到的错误信息都是固定的: {0:"Scrip ...
- elk 数据存储
让我们在集群中唯一一个空节点上创建一个叫做blogs的索引,默认情况下,一个索引被分配5个主分片, 但是为了演示的目的, 我们只分配3个主分片和一个复制分片(每个主分片都有一个复制分片): PUT / ...
- HDU 1076 An Easy Task
题解:枚举即可…… #include <cstdio> int main(){ int now,y,n,T,count; scanf("%d",&T); whi ...