Ueditor Baidu Editor to remove pictures online management (1/2)

Source: Internet
Author: User

Specific methods

First, find the image.html in dialogs/image/.

Delete code

The code is as follows Copy Code

<span tabsrc= "Imgmanager" ><var id= "Lang_tab_imgmanager" ></var></span>

and find the Image.js in the

The code is as follows Copy Code

if (id = = "Imgmanager") {
List.style.display = "";
Deprecated and no repeat commit request has been initialized
if (!list.children.length) {
Ajax.request (EDITOR.OPTIONS.IMAGEMANAGERURL, {
timeout:100000,
Action: "Get",
Onsuccess:function (XHR) {
Remove spaces
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;
}
} );
}
}

You can delete it!

the above is JS, we attached a net for Baidu text editor ueditor add image deletion function .

1, first modify the server-side ueditornet file imagemanager.ashx, increase the processing of picture deletion. As shown in the Add section of the following code:

The code is as follows Copy Code

<%@ 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"}; A list of directories that need to be traversed, preferably with a thumbnail address, or it can cause serious delays when the network is slow
string[] filetype = {". gif", ". png", ". jpg", ". jpeg", ". bmp"}; File Allow format

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

Directory validation
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
Delete the selected files
String Pathdel = String.                  Empty; It is best to use a thumbnail address, otherwise it can cause severe delay when the network speed is slow
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);

Directory validation
if (info. Exists)
{
Get the C:...ueditornetupload directory in the time named directory. such as: 2013-05-12
directoryinfo[] Infoarr = info. GetDirectories ();
foreach (DirectoryInfo tmpinfo in Infoarr)
{
foreach (FileInfo fi in Tmpinfo.getfiles ())
{
Determines whether the specified picture type, because the attachment and picture of the long pass are in the same directory
if (array.indexof, filetype, fi. Extension)!=-1)
{
if (FI. Name.equals (FileName))
{
FullPath = Pathdel + "/" + Tmpinfo.name + "/" + fileName;
File.delete (FullPath);
IsDeleted = true;
Break
}
}
}
has been removed, jumped out
if (isdeleted = = True)
Break
}
}
has been removed, jumped out
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;
}
}
}

home 1 2 last
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.