1, to click on the link, and then click inside the Upload tab, unfamiliar people may not find this upload function
2, insert is a link, I want to insert a link at the same time insert 1 pictures to represent the file type
Effect Chart:
Modify Fckconfig.js
1. In the fckconfig.toolbarsets["Default"] = Add ' Fujian ', the location of their own choice
2. Finally add 2 sentences
Attachment upload Address
Fckconfig.fujianurl = "/fckedit/upload.jsp";
Type of file uploaded
Fckconfig.fujianallowedextensions = ". (Doc|xls|ppt|pdf|rar|zip) $ ";
3. Add in the corresponding language pack:
Fujian: "Accessories"
4. Modification of Js/fckeditorcode_gecko.js and js/fckeditorcode_ie.js
Note: These 2 files are compressed, and clicking the formatted code in NetBeans will decompress it.
5. Found in the file: Case ' image ': b=new fckdialogcommand (' image ', Fcklang.dlgimgtitle, ' dialog/fck_image.html ', 450,390);
In front of this sentence, add:
Case ' Fujian ': b=new fckdialogcommand (' Fujian ', Fcklang.fujian, ' dialog/fck_fujian.html ', 450,200);
(This sentence means that when you click on the "Attachment" button to eject the dialog/fck_fujian.html page, 450,200 is wide, high).
and find
Case ' image ': b=new Fcktoolbarbutton (' image ', fcklang.insertimagelbl,fcklang.insertimage,null,false,true,37);
Add in front:
Case ' Fujian ': b=new Fcktoolbarbutton (' Fujian ', fcklang.fujian,null,null,false,true,77);
77 is the index of the icon to display on the toolbar for the attachment.
Icon files in: Editor/skins/default/fck_strip.gif files, icons are 16x16.
The button has been shown here, the following is the fck_image.html code:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>Upload</title>
<meta name= "Robots" content= "noindex, nofollow"/>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<script src= "Common/fck_dialog_common.js" src= "Common/fck_dialog_common.js" type= "Text/javascript" ></ Script>
<script src= "Fck_fujian/fck_fujian.js" src= "Fck_fujian/fck_fujian.js" type= "Text/javascript" ></script >
<body scroll= "No" style= "Overflow:hidden" style= "Overflow:hidden" >
<div id= "Divupload" style= "Display:none" style= "Display:none" >
<form id= "Frmupload" method= "Post target=" Uploadwindow "enctype=" Multipart/form-data "action=" "onsubmit=" return Checkupload (); " >
<span fcklang= "Dlglnkupload" > select uploaded files </span><br/>
<input id= "Txtuploadfile" style= "width:100%" type= "file" size= "a" name= "NewFile"/><br/>
<br/>
<input id= "Btnupload" type= "submit" value= "Upload" fcklang= "Dlglnkbtnupload"/>
<script type= "Text/javascript" ><!--
document.write (' <iframe name= "Uploadwindow" style= "Display:none" style= "Display:none" src= "' + Fcktools.getvoidurl () + ' "src=" ' + fcktools.getvoidurl () + ' ><\/iframe> ');
--></script>
</form>
</div>
</body>
Fck_fujian.js Code:
Copy Code code as follows:
/*
* Function: Upload attachment
*/
Show Page
var dialog = Window.parent;
var oeditor = dialog. Innerdialogloaded ();
var FCK = OEDITOR.FCK;
var Fcklang = Oeditor.fcklang;
var fckconfig = Oeditor.fckconfig;
var fckregexlib = Oeditor.fckregexlib;
var fcktools = Oeditor.fcktools;
Dialog. AddTab (' Upload ', fcklang.fujian,true);
Window.onload = function () {
Gete (' Frmupload '). Action = Fckconfig.fujianurl;
Show
Gete (' Divupload '). style.display = ';
}
var Ouploadallowedextregex = new RegExp (fckconfig.fujianallowedextensions, ' I ');
function Checkupload () {
var sfile = Gete (' Txtuploadfile '). Value;
if (Sfile.length = = 0) {
Alert (' Please select 1 files to upload ');
return false;
}
if (FCKConfig.FuJianAllowedExtensions.length > 0 &&!ouploadallowedextregex.test (sfile))
{
Onuploadcompleted (202);
return false;
}
Show animation
Window.parent.Throbber.Show (100);
Gete (' Divupload '). style.display = ' None ';
return true;
}
Upload complete.
function onuploadcompleted (errornumber, FileUrl, FileName, custommsg) {
Remove Animation
Window.parent.Throbber.Hide ();
Gete (' Divupload '). style.display = ';
Switch (errornumber) {
Case 0://No errors
Alert (' Your file has been successfully uploaded ');
InsertFile (Fileurl,filename)
break;
Case 1://Custom Error
alert (custommsg);
return;
Case://Custom Warning
alert (custommsg);
break;
Case 201:
Alert (' A file with the same name is already available. The uploaded file has been renamed to "' + FileName + '");
break;
Case 202:
Alert (' Unsupported file type ');
return;
Case 203:
Alert ("Security error.") You are probably don ' t have enough permissions to upload. Please check your server. ") ;
return;
Case 500:
Alert (' The connector is disabled ');
break;
Default:
Alert (' Error on file upload. Error number: ' + errornumber ';
return;
}
}
function InsertFile (fileurl,filename) {
Imgpath = getfileimg (fileName);
Inserting HTML
var html = "<div> <a href=" "+ FileUrl +" "href=" "+ fi Leurl + ">" + fileName + "</a></div>";
oEditor.FCK.InsertHtml (HTML);
Close page
Dialog. Cancel ();
}
function Getfileimg (fileName) {
var path = Fckconfig.basepath + "file/";
index = Filename.lastindexof (".");
if (index = = 1)
Return path + "Unknow.gif";
ext = FILENAME.SUBSTR (index+1);
Switch (Ext.tolowercase ()) {
Case "Doc":
Path = "Doc.gif"
Break
Case "PDF":
Path = "Pdf.gif"
Break
Case "ppt":
Path = "Ppt.gif"
Break
Case "XLS":
Path = "Xls.gif"
Break
Case "rar":
Path = "Rar.gif"
Break
Case "Zip":
Path = "Zip.gif"
Break
Default
Path = "Unknow.gif"
Break
}
return path;
}