在线涂改图片 php,php UEditor如何实现删除图片功能

在线涂改图片 php,php UEditor如何实现删除图片功能phpueditor删除图片的实现方法:首先找到“uedior/dialogs/image/image.js”文件并修改Add内容;然后打开“mageManager.php”文件并添加内容为“functiondelfile()”即可。php版给UEditor的图片在线管理栏目增加图片删除功能1.找到uedior/dialogs/image/image.js文件,Add为修改部分的代码:/***…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

php ueditor删除图片的实现方法:首先找到“uedior/dialogs/image/image.js”文件并修改Add内容;然后打开“mageManager.php”文件并添加内容为“function delfile()”即可。

7cfec1a3cd57b67eaad8b475f0664d25.png

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);

}

}

}

}

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/196384.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • springboot源码解析详细版

    springboot源码解析详细版springboot源码解析(转)SpringBoot的入口类@SpringBootApplicationpublicclassStartupApplication{publicstaticvoidmain(String[]args){SpringApplication.run(StartupApplication.class,args)…

    2022年5月1日
    56
  • CUDA性能优化—-kernel调优(nvprof工具的使用)

    CUDA性能优化—-kernel调优(nvprof工具的使用)1、引言本文主要介绍并行分析,涉及掌握nvprof的几个metrics参数,所用的例子是CUDA性能优化—-线程配置一文中所提到的sumMatrix2D.cu例子。接下来本文会做一些列的试验,测试环境:TeslaM2070一块,CUDA6.0,操作系统:RedHat4.1.2-50,gccversion4.1.220080704首先回顾一下sumMatrix2D的kern…

    2022年6月11日
    33
  • Eclipse断点调试

    Eclipse断点调试作为开发人员,掌握开发环境下的调试技巧十分有必要。去年就想把关于Eclipse断点调试总结下了,由于对时间的掌控程度仍需极大提高,结果拖到今年才写了此篇博文。关于java调试技术还有很多,如JavaDebugInterface等,依据具体项目的需要,还有很多值得去研究和学习的。该博文仅就Eclipse断点调试技巧做下总结,不足够的地方还请大牛们指点。1 Debug视图1.1线程堆栈

    2022年5月21日
    95
  • 借助栈来实现单链表的逆置运算_中缀后缀表达式互相转换

    借助栈来实现单链表的逆置运算_中缀后缀表达式互相转换原题链接算术表达式有前缀表示法、中缀表示法和后缀表示法等形式。日常使用的算术表达式是采用中缀表示法,即二元运算符位于两个运算数中间。请设计程序将中缀表达式转换为后缀表达式。输入格式:输入在一行中给出不含空格的中缀表达式,可包含+、-、*、\以及左右括号(),表达式不超过20个字符。输出格式:在一行中输出转换后的后缀表达式,要求不同对象(运算数、运算符号)之间以空格分隔,但结尾不得有多余空格。输入样例:2+3*(7-4)+8/4输出样例:2 3 7 4 – * + 8 4 / +注意

    2022年8月8日
    4
  • springboot+redis哨兵集群的yml配置 Cannot retrieve initial cluster partitions from initial URIs[通俗易懂]

    springboot+redis哨兵集群的yml配置 Cannot retrieve initial cluster partitions from initial URIs[通俗易懂]redis:单机模式时添加host:192.168.0.8port:6379timeout:5000lettuce:pool:#连接池中的最大空闲连接max-idle:8#连接池中的最小空闲连接min-idle:1#连接池最大阻塞等待时间(使用负值表示没有限制)max-wait:-1#连接池最大连接数(使用负值表示没有限制)max-active:50cluster:max-redirects:10nodes:192.168.0.8:63

    2022年6月26日
    417
  • (1)美团面试题:Hashmap的结构,1.7和1.8有哪些区别,史上最深入的分析「建议收藏」

    (一)真实面试题之:Hashmap的结构,1.7和1.8有哪些区别不同点:(1)JDK1.7用的是头插法,而JDK1.8及之后使用的都是尾插法,那么他们为什么要这样做呢?因为JDK1.7是用单链表进行的纵向延伸,当采用头插法就是能够提高插入的效率,但是也会容易出现逆序且环形链表死循环问题。但是在JDK1.8之后是因为加入了红黑树使用尾插法,能够避免出现逆序且链表死循环的问题。(2)扩…

    2022年4月9日
    37

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号