php版给UEditor的图片在线管理栏目增加图片删除功能
1.找到uedior/dialogs/image/image.js文件,Add为修改部分的代码:
/**
* tab点击处理事件
* @param tabHeads
* @param tabBodys
* @param obj
*/
function clickHandler(tabHeads, tabBodys, obj) {
//head样式更改
for (var k = 0,
len = tabHeads.length; k < len; k++) {
tabHeads[k].className = "";
}
obj.className = "focus";
//body显隐
var tabSrc = obj.getAttribute("tabSrc");
for (var j = 0,
length = tabBodys.length; j < length; j++) {
var body = tabBodys[j],
id = body.getAttribute("id");
body.onclick = function() {
this.style.zoom = 1;
};
if (id != tabSrc) {
body.style.zIndex = 1;
} else {
body.style.zIndex = 200;
//当切换到本地图片上传时,隐藏遮罩用的iframe
if (id == "local") {
toggleFlash(true);
maskIframe.style.display = "none";
//处理确定按钮的状态
if (selectedImageCount) {
dialog.buttons[0].setDisabled(true);
}
} else {
toggleFlash(false);
maskIframe.style.display = "";
dialog.buttons[0].setDisabled(false);
}
var list = g("imageList");
list.style.display = "none";
//切换到图片管理时,ajax请求后台图片列表
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 ? " " + lang.noUploadImage: "";
for (var k = 0,ci; ci = imageUrls[k++];) {
//Add Start===============================
var div = document.createElement("div");
var img = document.createElement("img");
var del = document.createElement("img");
var p = document.createElement("p"); div.appendChild(img);
div.appendChild(p);
p.appendChild(del);
div.style.display = "none"; img.style.height = "100px";
img.style.width = "100px";
del.setAttribute("src", "images/del.png");
p.style.marginTop = "-104px";
p.style.marginLeft = "90px"; g("imageList").appendChild(div);
img.onclick = function() {
changeSelected(this);
}; del.onclick = function() {
var me = this,
src = me.getAttribute("alt", 2);
var pic = me.parentNode.parentNode.childNodes[0];
if (!confirm("删除操作不可恢复,您确认要删除本图片么?")) return;
ajax.request(editor.options.imageManagerUrl, {
action: "del",
fileName: src.substr(src.lastIndexOf("/") + 1),
onsuccess: function(xhr) {
me.parentNode.parentNode.removeChild(pic);
me.parentNode.removeChild(me);
},
onerror: function(xhr) {
alert("服务器删除图片失败,请重试!");
}
});
};
//Add End================================
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;
this.onload = null;
};
img.setAttribute(k < 35 ? "src": "lazy_src", editor.options.imageManagerPath + ci.replace(/\s+|\s+/ig, ""));
img.setAttribute("title", editor.options.imageManagerPath + ci.replace(/\s+|\s+/ig, ""));
img.setAttribute("width", "100px");
img.setAttribute("height", "100px"); del.onload = function() { //设置加载del图片时的样式
this.style = "border:0";
this.onload = null;
};
del.setAttribute("alt", editor.options.imageManagerPath + ci.replace(/\s+|\s+/ig, ""));
}
},
onerror: function() {
g("imageList").innerHTML = lang.imageLoadError;
}
});
}
}
if (id == "imgSearch") {
selectTxt(g("imgSearchTxt"));
}
if (id == "remote") {
$focus(g("url"));
}
}
}
}
找到uedior/php/imageManager.php文件,增加以下内容:
if ($action == "del") {
$fileName = $_POST['fileName'];
foreach($paths as $path) {
$str1 = delfiles($fileName, $path);
break;
}
} function delfiles($fileName, $path, &$files = array()) {
if (!is_dir($path)) return null;
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
$path2 = $path.'/'.$file;
if (is_dir($path2)) {
delfiles($fileName, $path2, $files);
} else {
if (preg_match("/\.(gif|jpeg|jpg|png|bmp)$/i", $file)) {
$path3 = str_replace('../../', '/static/', $path2);
$fileImg = basename($path3);
if ($fileImg == $fileName) {
$is_del = unlink($path2);
}
}
}
}
}
}
php版给UEditor的图片在线管理栏目增加图片删除功能的更多相关文章
- jsp版ueditor图片在线管理返回绝对路径
引用:http://zhengyunfei.iteye.com/blog/2149979 如果你有富文本编辑器的功能需要开发,我推荐你用百度的ueditor.本文将与你分享jsp版ueditor开发中 ...
- 解决ueditor编辑器图片在线管理图片无法显示
使用ueditor,点击在线管理,服务器图片路径显示不正确,如下图所示 查看源码,如下: 发现图片src中中间多了一长串的项目跟路径,解决的办法是 把 jsp/controller.jsp 里面 ...
- Ueditor结合七牛云存储上传图片、附件和图片在线管理的实现和最新更新
最新下载地址: https://github.com/widuu/qiniu_ueditor_1.4.3 Ueditor七牛云存储版本 注意事项 老版本请查看 : https://github.com ...
- UEditor1.4.3.3实现图片上传、删除功能
1.下载ueditor1.4.3.3 UTF-8的版本 2.新建一个项目,在项目中添加UEditor,把下载好的插件都放在ueditor这个文件夹中,在进行一些基本的配置 3.在根目录下新建一个为in ...
- C#设计模式总结 C#设计模式(22)——访问者模式(Vistor Pattern) C#设计模式总结 .NET Core launch.json 简介 利用Bootstrap Paginator插件和knockout.js完成分页功能 图片在线裁剪和图片上传总结 循序渐进学.Net Core Web Api开发系列【2】:利用Swagger调试WebApi
C#设计模式总结 一. 设计原则 使用设计模式的根本原因是适应变化,提高代码复用率,使软件更具有可维护性和可扩展性.并且,在进行设计的时候,也需要遵循以下几个原则:单一职责原则.开放封闭原则.里氏代替 ...
- ueditor1.4.3jsp版成功上传图片后却回显不出来与在线管理显示不出图片的解决方案
这是因为路径问题,可以在jsp/config.json这个文件去改路径 通过“imageUrlPrefix”与“imagePathFormat”这两个属性去拼凑路径. “imageUrlPrefix” ...
- dedecmsV5.7 百度编辑器ueditor 多图上传 在线管理 排序问题
问题:dedecms后台百度编辑器ueditor的多图上传-在线管理的图片排序有问题,想把这个顺序调成按照文件修改时间倒序来展示 解决方法: 1.打开/include/ueditor/php/acit ...
- 使用uEdit时,在线管理图片功能不可用
把所有的配置文件都配置好了,uedit的在线管理功能图片还是不可用,看了一下源码: 是的,它在img的src属性后边的图片上加上了参数,那肯定不能用啊,所以修改源文件image.js.直接搜索noCa ...
- .NET下为百度文本编辑器UEditor增加图片删除功能
[摘要:比来写了个项目,用到了UEditor,但是UE并出有文件删除功效 然后网上找若何增加 找半天只能找到一个1.2.X的 以是便摹仿PHP的 改成了.NET的 PHP本文 第一步 (增加背景删除地 ...
随机推荐
- w25q128 优化读写函数
#include "w25qxx.h" #include "spi.h" #include "delay.h" #include & ...
- Qt乱码解决办法(常量中有换行符)
用记事本打开源代码,然后点另存为,utf-8,编码覆盖 QStringLiteral("打开相机")
- ORA-12504:tns:监听程序在 CONNECT_DATA中未获得SERVICE_NAME
在VS2008中创建一个数据源时,提示以下错误 “ORA-12504:tns:监听程序在 CONNECT_DATA中未获得SERVICE_NAME” 本机安装ORACLE客户端,找出以下路径的文件D: ...
- [HDU1109]模拟退火算法
模拟退火的基本思想: (1) 初始化:初始温度T(充分大),初始解状态S(是算法迭代的起点),每个T值的迭代次数L (2) 对k=1,……,L做第(3)至第6步: (3) 产生新解$S\prime $ ...
- mongodb插入时间
插入时间: db.test.insert({time:new Date()}) 给mongodb插入日期格式的数据时发现,日期时间相差8个小时,原来存储在mongodb中的时间是标准时间UTC +0: ...
- 并行fp-growth图解(mahout)
FP-growth Apriori算法的一个主要瓶颈在于,为了获得较长的频繁模式,需要生成大量的候选短频繁模式.FP-Growth算法是针对这个瓶颈提出来的全新的一种算法模式.目前,在数据挖掘领域,A ...
- Entity Framework Code-First(8):Configure Domain Classes
Configure Domain Classes in Code-First: We learned default Code-First Conventions in the previous se ...
- jquery选择器中的find和空格,children和>的区别、及父节点兄弟节点,还有判断是否存在的写法
一.find和空格,children和>及其它的区别 空格:$('parent childchild')表示获取parent下的所有的childchild节点(所有的子孙). 等效成 = ...
- raspberry是个什么玩意
今天Wilson同学取回一个书本大小的包裹,说买回来一台小电脑,只有信用卡大小! 这是第一次听说和看见raspberry Pi. 一块开发板上有四个USB.一个视频接口.一个音频接口.一个网线接口和电 ...
- 整数划分——真正的递归经典例题(NYOJ——90)
先注明学习博客的地址:(http://www.cnblogs.com/hoodlum1980/archive/2008/10/11/1308493.html) 题目描述:任何正整数n都可以写成n=n1 ...