ckfinder不是不好,好好,就是不知道怎么用ftp,没查到资料有讲,所以自已搞,步骤就4个
1.修改ckeditor的配置文件ckeditor/config.js,把上传地址指向自已的页面
//处理上传的文件
config.filebrowserUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Files';
config.filebrowserImageUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Images';
config.filebrowserFlashUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Flash';
config.filebrowserUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Files';
config.filebrowserImageUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Images';
config.filebrowserFlashUploadUrl = '/ckeditor/Update.aspx?command=QuickUpload&type=Flash';
2.接收ckeditor里<input type="file">控件传递过来的数据
在ckeditor/Update.aspx里,使用:Request.Files[0],比如:
Response.Write("<br />" + Request.Files[0].FileName);
这一句可以写出要上传的文件名
3.按自已的需要写上传代码
4.把得到的文件名返回给ckeditor
如果上传失败:
string fileName, errMsg = "test error: 'it is just a test'";
fileName = "";
errMsg = errMsg.Replace("'", "\'");
Response.Write(String.Format("<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction({0}, '{1}', '{2}');</script>",
Request.QueryString["CKEditorFuncNum"],
fileName,
errMsg));
fileName = "";
errMsg = errMsg.Replace("'", "\'");
Response.Write(String.Format("<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction({0}, '{1}', '{2}');</script>",
Request.QueryString["CKEditorFuncNum"],
fileName,
errMsg));
如果上传成功:
string fileName = "http://www.baidu.com/img/baidu_sylogo1.gif", errMsg = "";
Response.Write(String.Format("<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction({0}, '{1}', '{2}');</script>",
Request.QueryString["CKEditorFuncNum"],
fileName,
errMsg));
Response.Write(String.Format("<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction({0}, '{1}', '{2}');</script>",
Request.QueryString["CKEditorFuncNum"],
fileName,
errMsg));
这个可以看这里:http://zerokspot.com/weblog/2009/09/09/custom-filebrowser-callbacks-ckeditor/
如果是浏览服务器时,选中了一个文件要返回,调用的脚本是:
window.opener.CKEDITOR.tools.callFunction(CKEditorFuncNum, url);
如果是上传完,要把文件地址返回给ckeditor,调用的脚本是:
window.parent.CKEDITOR.tools.callFunction(CKEditorFuncNum, url, errorMessage);
这里就是上传了,如果成功,设置errorMessage = "",给出文件地址,如果失败,设置url = "",给出出错的消息,ckeditor会alert出这个消息
就这几步,自已的上传页面就可以和CKEditor整合起来了,喜欢怎么上传都可以,自已上个够好了