国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php版給UEditor的圖片在線治理欄目增加圖片刪除功能

php中文網(wǎng)
發(fā)布: 2016-06-13 12:01:00
原創(chuàng)
1144人瀏覽過

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;            //當(dāng)切換到本地圖片上傳時,隱藏遮罩用的iframe            if (id == "local") {                toggleFlash(true);                maskIframe.style.display = "none";                //處理確定按鈕的狀態(tài)                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 = "";                //已經(jīng)初始化過時不再重復(fù)提交請求                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("刪除操作不可恢復(fù),您確認(rèn)要刪除本圖片么?")) 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("服務(wù)器刪除圖片失敗,請重試!");                                        }                                    });                                };                                //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() { //設(shè)置加載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"));            }        }    }}
登錄后復(fù)制

找到uedior/php/imageManager.php文件,增加以下內(nèi)容:

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);                    }                }            }        }    }}
登錄后復(fù)制




立即學(xué)習(xí)PHP免費(fèi)學(xué)習(xí)筆記(深入)”;


立即學(xué)習(xí)PHP免費(fèi)學(xué)習(xí)筆記(深入)”;

PHP速學(xué)教程(入門到精通)
PHP速學(xué)教程(入門到精通)

PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!

下載
來源:php中文網(wǎng)
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn
最新問題
開源免費(fèi)商場系統(tǒng)廣告
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號