编程人生

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

CuteEditor编辑器功能很强大,也很丰富,不过再好的东西也有缺点.
这个编辑器上传图片是把所有图片都放到根目录下的upload文件夹中,编辑器也不是自动命名图片,这时候图片就可能会重名,在网上找了许久,用的人也不多,方法也没找到,最后还是自己写把!
CuteSoft_Client\CuteEditor\Dialogs\下的
Gecko_InsertImage.Frame.aspx
InsertImage.Frame.aspx
SelectImage.Frame.aspx
操作插入图片的3个文件夹
在头部加入引用
<%@ Import Namespace="System.IO" %>
找到
            protected override void InitOfType()
            {
                fs.VirtualRoot = CuteEditor.EditorUtility.ProcessWebPath(Context, null, secset.ImageGalleryPath).TrimEnd('/') + "/";
            }
替换成
            protected bool myCreateDirectory(string path)
            {
                try
                {
                    if (Directory.Exists(path))
                    {
                        Response.Write("目录已经存在!");
                        return true;
                    }
                    else
                    {
                        DirectoryInfo di = Directory.CreateDirectory(path);
                        Response.Write("目录应创建成功!");
                        return true;
                    }
                }
                catch
                {
                    Response.Write("出现异常!");
                    return false;
                }
                finally { }
            }
            protected override void InitOfType()
            {

                string username = Request.Cookies["hnusername"].Value;

                string filename = Server.MapPath(secset.ImageGalleryPath + "/" + username);
                if (myCreateDirectory(filename))
                {
                    fs.VirtualRoot = CuteEditor.EditorUtility.ProcessWebPath(Context, null, filename).TrimEnd('/') + "/";
                }
                else
                {
                    fs.VirtualRoot = CuteEditor.EditorUtility.ProcessWebPath(Context, null, secset.ImageGalleryPath).TrimEnd('/') + "/";
                }
            }

3个文件一样就OK,然后每个用户就有自己可以使用的文件夹了.
编辑器有2个上传图片功能的按钮,把前面的一个改成只能插入图片,不能上传图片.
如果不想改很多,只要把上传的功能隐藏就可以.这样前面的上传按钮就改成了只能插入图片,并且可以插入所有用户已经上传的图片.
OK

           

posted on 2006-09-06 20:34  choice  阅读(1243)  评论(0编辑  收藏  举报