Add picture deletion to fckeditor text editor

Source: Internet
Author: User
Tags php file


Locate the frmresourceslist.html file in the Fckeditoreditorfilemanagerbrowserdefault folder and modify the code as follows

Olistmanager.getfilerowhtml found here, the following code replaces the original code

The code is as follows Copy Code
olistmanager.getfilerowhtml = function (FileName, FILEURL, fileSize) {
Build the link to view the folder.
var slink = ' <a href= ' # "mce_href=" # "onclick=" OpenFile (' + protectpath (FILEURL) + '); return false; " > Selection </a> ';

Get the file icon.
var Sicon = Oicons.geticon (fileName);

Return ' <div class= "piclist" ><p> ' + slink + ' <a href= ' # "mce_href=" # "onclick=" DeleteFile (' + protectpath (FILEURL) + '); " style= "COLOR: #FF9933;" mce_style= "color: #FF9933;" > Delete </a></p></div> '
;
}

In the Add a
<script type= "Text/javascript" src= "/js/ajaxdel.js" ></script>
Ajaxdel.js file

The code is as follows Copy Code
Picture deletion feature ******************************************
var req; Defines variables that are used to create XMLHttpRequest objects

Produces a random number that is not repeated
var rn = Math.ceil (Math.random () * 1000000);
var rnch = RN;

function Rndnum () {
while (rn = = rnch) rn = Math.ceil (Math.random () * 1000000);
Rnch = RN;
return RN;
}

Delete file, Ajax start
function DeleteFile (file) {
var url = "/ajaxpic.php?filepath=" + escape (file) + "&ud=" + rndnum (); Service-side address to request
if (window. XMLHttpRequest)//non IE browser and IE7 (version 7.0 and above), with XMLHttpRequest object to create Built
{
req = new XMLHttpRequest ();
}
else if (window. ActiveXObject)//ie (version 6.0 and below) browsers are created with ActiveXObject objects if the user's browser disables ActiveX, may fail.
{
req = new ActiveXObject ("Microsoft.XMLHTTP");
}

if (req)///successfully created XMLHttpRequest
{
Req.open ("Get", url, True); Establish a connection to the server (Request mode post or get, address, true to indicate asynchronous)
Req.onreadystatechange = callback; Specifying callback Functions
Req.send (NULL); Send Request
}
}

function callback () {
if (Req.responsetext ==1)
{
Alert (' Delete successful! ');
Refresh ();
}
Else
{
Alert (' Delete failed! ');
}//, refresh yourself.
}

ajaxpic.php file saved as ajaxpic.php

The code is as follows Copy Code

?
$root = DirName (__file__);
$filePath = isset ($_get[' FilePath '])? $_get[' FilePath ']: ';
if (unlink ($root. $filePath))
{
echo ' 1 ';
}
Else
{
echo ' 0 ';
}
?>

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.