FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器。它志于轻量化,不需要太复杂的安装步骤即可使用。它可和PHP、JavaScript、ASP、ASP.NET、ColdFusion、Java、以及ABAP等不同的编程语言相结合。“FCKeditor”名称中的“FCK” 是这个编辑器的作者的名字Frederico Caldeira Knabben的缩写。

FCKeditor是开源的,而且效果不错。FCKeditor的插件是对FCKeditor的扩展功能。

尽管一般条件下FCKeditor能适应使用,但你可能对FCKeditor仅有的功能不满意,FCKeditor提供了插件开放功能,好,我就来试试。

本人一直对于FCKeditor的文件上传功能很是不满,so,经过在网上多翻查找,找到一款多文件上传的小插件--uploadify。很棒的一个小东西。

我们先了解下FCKeditor插件的目录结构和一些命令。

插件的目录结构:插件目录的名称必须和插件的名称一样,而且目录里面必须包含一个fckplugin.js文件。lang目录用来实现界面的国际化的一些js文件,是可选的。每一个文件定义一种语言,文件名不包含.js,用FCKConfig.Plugins.Add()注册。如果实现的插件命令没有界面,也可以不需要支持任何语言。

我的实例目录结构:

fckeditor/editor/plugins/uploadify/fckplugin.js

fckeditor/editor/plugins/uploadify/lang/en.js

fckeditor/editor/plugins/uploadify/lang/zh-cn.js

fckeditor/editor/plugins/uploadify/inc/*.*   (uploadify相关的有文件)

fckeditor/editor/plugins/uploadify/index.html     (FCKeditor调用文件,用于上传界面)

fckeidtor/editor/plugins/uploadify/btn.png   (用于显示在FCKeditor主界面上工具栏中)

在fckplugin.js文件中定义你的插件,同时也应该注册改命令,以及创建一个工具栏按钮。

命令详解:

1.注册命令
FCKCommands.RegisterCommand(命令名称,对话框命令)

2.对话框命令
FCKDialogCommand(命令名称,对话框标题,URl,宽度,高度)

3.定义工具栏
FCKToolbarButton(命令名称,按钮标题)

4.添加一个图标
IconPath=图标地址

5.注册到工具栏
FCKToolbarItems.RegisterItem(命令名称,工具栏);

插件机制:注册命令-定义工具栏-注册到工具栏

我的fckplugin.js文件内容

//注册
FCKCommands.RegisterCommand(
'uploadify',
new FCKDialogCommand(
'uploadify',
FCKLang.uploadifyDlgTitle,
FCKPlugins.Items['uploadify'].Path + "index.html",800,600
)
);
//定义工具栏
var ouploadifyItem = new FCKToolbarButton('uploadify', FCKLang.uploadify);
ouploadifyItem.IconPath = FCKPlugins.Items['uploadify'].Path + 'btn.png';
//注册
FCKToolbarItems.RegisterItem('uploadify', ouploadifyItem);

Fckeditor插件的语言文件命名方式是:

国家或地区.js。如中国是zh.js.简体中文是zh-cn.js.英文是en.js等等。我们建立两个”en.js”和”zh-cn.js”。
然后编辑语言文件。

FCKeditor插件语言的命名方式为:FCKLang.变量名=”语言定义”

我们编辑”en.js”。

我的en.js文件内容

FCKLang.uploadifyBtn = 'Insert/upload files';
FCKLang.uploadifyDlgTitle = 'uploadify plugin';
暂时先到这,呵呵,我也现学现卖!!
 

下面的文件就是操作的界面,也就是一个HTML文件,界面文件中应该包含如下语句.

<script language="javascript">
var dialog = window.parent ;
var oEditor = dialog.InnerDialogLoaded() ;
var FCKLang = oEditor.FCKLang ;
</script>

我的界面文件index.html内容如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
<link href="inc/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="inc/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="inc/swfobject.js"></script>
<script type="text/javascript" src="inc/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript">
var oEditor = window.parent.InnerDialogLoaded() ;
var FCK = oEditor.FCK ;
var FCKLang = oEditor.FCKLang ; window.onload = function (){
window.parent.SetOkButton(true);
//加载界面的OK按钮
} function Ok()
{
FCK.InsertHtml(document.getElementById('info2').value);
//插入ID="info2"文本控件的内容到FCKeditor的编辑器内容
return true ;
} $(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : 'inc/uploadify.swf',
'script' : 'upload.asp',
'cancelImg' : 'inc/cancel.png',
'folder' : '/userfiles',
'auto' : false,
'multi' : true,
'sizeLimit':1024*1024*10,
'buttonText': 'Pickup Files',
'queueID': 'fileQueue',
'buttonImg': 'inc/select.jpg',
'fileDesc' :'*.gif,*.jpg,*.png',
'fileExt' : '*.gif;*.jpg;*.png',
'onComplete':function(event,queueId,fileObj,response,data){
$('#info2').text($('#info2').text() + '<p><img src="'+response+'" ></p>\r');
//在页面上显示已上传文件的相对路径
$('#info').append($('#info').text() + '<img src="'+response+'" >\r');
//在页面上显示已上传的图片
}
});
});
</script>
</head>
<body>
<div id="fileQueue"><!--上传文件的列表--></div>
<input id="file_upload" name="file_upload" type="file" />
<p>
<a href="javascript:$('#file_upload').uploadifyUpload()">上传</a>|
<a href="javascript:$('#file_upload').uploadifyClearQueue()">取消上传</a>
</p>
<div id="info" ></div>
<textarea name="info2" id="info2" cols="45" rows="5"></textarea>
</body>
</html>

FCKeditor插件开发实例:uploadify多文件上传插件的更多相关文章

  1. Uploadify多文件上传插件.NET使用案例+PHP使用案例

    ploadify是一个非常好用的多文件上传插件 插件下载:http://www.uploadify.com 下载后需要用到的文件: 接下来就是直接添加代码: Default.aspx代码 <%@ ...

  2. uploadify多文件上传实例--C#

    下载uploadify文件 http://www.uploadify.com/ HTML(视图) <html lang="zh-cn"> <head> &l ...

  3. jquery uploadify文件上传插件用法精析

      jquery uploadify文件上传插件用法精析 CreationTime--2018年8月2日11点12分 Author:Marydon 一.参数说明 1.参数设置 $("#fil ...

  4. 详解jQuery uploadify文件上传插件的使用方法

    uploadify这个插件是基于js里面的jquery库写的.结合了ajax和flash,实现了这个多线程上传的功能. 现在最新版为3.2.1. 在线实例 实例中用到的php文件UploaderDem ...

  5. 强大的支持多文件上传的jQuery文件上传插件Uploadify

    支持多文件上传的jQuery文件上传插件Uploadify,目前此插件有两种版本即Flash版本和HTML5版本,对于HTML5版本会比较好的支持手机浏览器,避免苹果手机Safari浏览器不支持Fla ...

  6. jQuery文件上传插件Uploadify(转)

    一款基于flash的文件上传,有进度条和支持大文件上传,且可以多文件上传队列. 这款在flash的基础上增加了html5的支持,所以在移动端也可以使用. 由于官方提供的版本是flash免费,html5 ...

  7. jQuery 文件上传插件:uploadify、swfupload

    jQuery 文件上传插件: uploadify.swfupload

  8. 一款基于uploadify扩展的多文件上传插件,完全适用于Html5

    http://www.uploadify.com/documentation/  官网里面有两个插件,一个是要使用flash插件才能文件上传的插件,另外一个是不需要使用要flash插件的文件上传插件完 ...

  9. 多文件上传插件Stream,是Uploadify的Flash版和Html5版的结合,带进度条,并支持html5断点续传(附件上传),拖拽等功能

    是根据某网的文件上传插件加工而来,支持不同平台(Windows, Linux, Mac, Android, iOS)下,主流浏览器(IE7+, Chrome, Firefox, Safari, 其他) ...

随机推荐

  1. Visual Studio的广告剧

    一个热衷于code的developer,一个热衷于developer的girl,他们将发生怎样的故事? 第一集:<想做你的Code> 第二集:<让爱延长> 第三集:<幸福 ...

  2. iOS开发之常用第三方框架(下载地址,使用方法,总结)

    iOS开发之常用第三方框架(下载地址,使用方法,总结) 说句实话,自学了这么久iOS,如果说我不知道的但是又基本上都摸遍了iOS相关知识,但是每次做项目的时候,遇到难一点的地方或者没试过的东西就闷了. ...

  3. Java学习笔记--xml构造与解析之Sax的使用

    汇总:xml的构造与解析 http://www.cnblogs.com/gnivor/p/4624058.html 参考资料:http://www.iteye.com/topic/763895 利用S ...

  4. JAVA_build_ant_Tstamp

    Description Sets the DSTAMP, TSTAMP, and TODAY properties in the current project. By default, the DS ...

  5. iOS界面调试工具 Reveal-备用

    Reveal是一个iOS程序界面调试工具.使用Reveal,我们可以在iOS开发时动态地查看和修改应用程序的界面. 对于动态或复杂的交互界面,手写UI是不可避免的.通过Reveal,我们可以方便地调试 ...

  6. InputStream转为byte数组

    InputStream is = request.getSession().getServletContext().getResourceAsStream("/WEB-INF/swdjzbg ...

  7. cf B. Road Construction

    http://codeforces.com/contest/330/problem/B这道题可以围着一个可以与任何一个城市建路的城市建设. #include <cstdio> #inclu ...

  8. 从vector容器中查找一个子串:search()算法

    如果要从vector容器中查找是否存在一个子串序列,就像从一个字符串中查找子串那样,次数find()与find_if()算法就不起作用了,需要采用search()算法:例子: #include &qu ...

  9. Global build settings

    [ ] Select all packages by default *** General build options ***   [ ] Show packages that require gr ...

  10. CH Round #53 -密室

    描述 有N个密室,3种钥匙(红色,绿色,白色)和2种锁(红色,绿色),红色钥匙只能开红色的锁,绿色钥匙只能开绿色的锁,白色钥匙可以开红色的锁和绿 色的锁,一把钥匙使用一次之后会被扔掉.每个密室由一扇门 ...