Ajax PHP Implementation to fckeditor text editor Add picture deletion function _ Web Editor

Source: Internet
Author: User
The work needs the FCK Editor's server browsing adds the picture deletion function, we use the Ajax PHP realization the need friend to be possible to refer to under.
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
Copy Code code as follows:

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) + '); "St yle= "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
Copy Code code as follows:

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), created with XMLHttpRequest object
{
req = new XMLHttpRequest ();
}
else if (window. ActiveXObject)//ie (version 6.0 and below) browsers are created with ActiveXObject objects and may fail if the user's browser disables ActiveX.
{
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
Copy Code code as follows:

?
$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.