网站地图    收藏   

主页 > 前端 > javascript >

ueditor百度编辑器去掉图片的在线管理(1/2)

来源:自学PHP网    时间:2014-09-19 14:47 作者: 阅读:

[导读] 有的时间我们并不希望编辑器有在线管理功能,如我们的留言板肯定是不希望让其它用户可以直接有图片在线管理功能的,那么我们要如何删除呢,下面本文章来给大家介绍删除百度编...

具体方法

首先找到dialogs/image/中的image.html

删除代码

 代码如下 复制代码

<span tabSrc=”imgManager”><var id=”lang_tab_imgManager”></var></span>

然后找到image.js中的

 代码如下 复制代码

if ( id == “imgManager” ) {
list.style.display = “”;
//已经初始化过时不再重复提交请求
if ( !list.children.length ) {
ajax.request( editor.options.imageManagerUrl, {
timeout:100000,
action:”get”,
onsuccess:function ( xhr ) {
//去除空格
var tmp = utils.trim(xhr.responseText),
imageUrls = !tmp ? [] : tmp.split( “ue_separate_ue” ),
length = imageUrls.length;
g( “imageList” ).innerHTML = !length ? “&nbsp;&nbsp;”+lang.noUploadImage : “”;
for ( var k = 0, ci; ci = imageUrls[k++]; ) {
var img = document.createElement( “img” );
var div = document.createElement( “div” );
div.appendChild( img );
div.style.display = “none”;
g( “imageList” ).appendChild( div );
img.onclick = function () {
changeSelected( this );
};
img.onload = function () {
this.parentNode.style.display = “”;
var w = this.width, h = this.height;
scale( this, 100, 120, 80 );
this.title = lang.toggleSelect + w + “X” + h;
};
img.setAttribute( k < 35 ? “src” : “lazy_src”, editor.options.imageManagerPath + ci.replace(/s+|s+/ig,”") );
img.setAttribute( “data_ue_src”, editor.options.imageManagerPath + ci.replace(/s+|s+/ig,”") );
}
},
onerror:function () {
g( “imageList” ).innerHTML = lang.imageLoadError;
}
} );
}
}

删除即可!

上面是js的我们再附一篇NET下为百度文本编辑器UEditor增加图片删除功能 .

1、首先修改服务器端ueditornet下的文件imageManager.ashx,增加图片删除的处理。如下代码的Add部分所示:

 代码如下 复制代码

<%@ WebHandler Language="C#" Class="imageManager" %>
/**
 * Created by visual studio2010
 * User: xuheng
 * Date: 12-3-7
 * Time: 下午16:29
 * To change this template use File | Settings | File Templates.
 */
using System;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;

public class imageManager : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
       
       
        string[] paths = { "upload", "upload1" }; //需要遍历的目录列表,最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
        string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };                //文件允许格式

        string action = context.Server.HtmlEncode(context.Request["action"]);

        if (action == "get")
        {
            String str = String.Empty;
           
            foreach (string path in paths)
            {
                DirectoryInfo info = new DirectoryInfo(context.Server.MapPath(path));

                //目录验证
                if (info.Exists)
                {
                    DirectoryInfo[] infoArr = info.GetDirectories();
                    foreach (DirectoryInfo tmpInfo in infoArr)
                    {
                        foreach (FileInfo fi in tmpInfo.GetFiles())
                        {
                            if (Array.IndexOf(filetype, fi.Extension) != -1)
                            {
                                str += path+"/" + tmpInfo.Name + "/" + fi.Name + "ue_separate_ue";
                            }
                        }
                    }
                }
            }
          
            context.Response.Write(str);
        }

        //Add Start========================================================== 2013-05-12
        //删除选中的文件
        string pathDel = string.Empty;                  //最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
        string fileName = context.Server.HtmlEncode(context.Request["fileName"]);
        bool isDeleted = false;
        if (action == "del")
        {
            try
            {
               
                String fullPath = String.Empty;
                foreach (string path in paths)
                {
                    pathDel = context.Server.MapPath(path);
                    DirectoryInfo info = new DirectoryInfo(pathDel);

                    //目录验证
                    if (info.Exists)
                    {
                        //获得C:...ueditornetupload目录下,以时间命名的目录。如:2013-05-12
                        DirectoryInfo[] infoArr = info.GetDirectories();
                        foreach (DirectoryInfo tmpInfo in infoArr)
                        {
                            foreach (FileInfo fi in tmpInfo.GetFiles())
                            {
                                //判断是否是指定的图片类型,因为长传的附件和图片在同一个目录
                                if (Array.IndexOf(filetype, fi.Extension) != -1)
                                {
                                    if (fi.Name.Equals(fileName))
                                    {
                                        fullPath = pathDel + "/" + tmpInfo.Name + "/"+ fileName;
                                        File.Delete(fullPath);
                                        isDeleted = true;
                                        break;
                                    }
                                }
                            }
                            //已经删除,往外跳出
                            if (isDeleted == true)
                                break;
                        }
                    }
                    //已经删除,往外跳出
                    if (isDeleted == true)
                        break;
                }
                isDeleted = false;
                context.Response.Write("success");
            }
            catch
            {
                context.Response.Write("error");
            }
        }
        //Add End============================================================  2013-05-12
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论