Maison >développement back-end >tutoriel php >php版给UEditor的图片在线治理栏目增加图片删除功能
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 <br>找到uedior/php/imageManager.php文件,增加以下内容:<p></p><pre code_snippet_id="411463" snippet_file_name="blog_20140630_2_2324623" name="code" class="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); } } } } }}