Use fckeditor2.6.3 in. Net 3.5/4.0

Source: Internet
Author: User

Explain Source: http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Integration/ASP.NET

Code source fckeditor2.6.4: http://sourceforge.net/project/downloading.php? Group_id1_75348&filename=fckeditor_2.6.4.zip

Code source fckeditor2.6.3 net: http://www.fckeditor.net/download

1. Download
Fckeditor_2.6.3.zip (Core File)
Fckeditor.net_2.6.3.zip (. Net Control)

2. Deploy to the. NET Website
// Decompress fckeditor_2.6.3.zip and rename the fcktools root directory to the root directory of the website. (The operation is unnecessary)
Create a folder fckfiles in the root directory of the website to store uploaded files.
Use "fredck. fckeditorv2.dll" in fckeditor.net_2.6.3.zip to copy files to the bin directory of the website.

In. in the. NET toolbox, right-click the General Panel and choose [select item]. In the displayed "select toolbox item" dialog box, select [.. NET Framework component], click [browse] To Find The fredck. fckeditorv2.dll file. After correct addition, you can see the FCKeditor Control in the toolbox.

3. Simplify fck Configuration
Delete all files and folders starting with _. In filemanager, delete folders other than aspx in connector.

4. Modify the fck Language
Fckconfig. js in FCKeditor
61 ~ 63 rows
Fckconfig. autodetectlanguage = false;
Fckconfig. defaultlanguage = 'zh-cn ';
Fckconfig. contentlangdirection = 'ltr ';

5. ModifyProgramLanguage type
Fckconfig. js in FCKeditor
276 ~ 277 rows

VaR _ filebrowserlanguage = 'aspx '; // ASP | aspx | CFM | lasso | Perl | PHP | py
VaR _ quickuploadlanguage = 'aspx '; // ASP | aspx | CFM | lasso | Perl | PHP | py

Web. config->

<Deleetask>
<Add key = "FCKeditor: basepath" value = "/fcktools/"/>
<Add key = "FCKeditor: userfilespath" value = "/fckfiles/"/>
</Appsettings>

Default. aspx->

<% @ Page Language = "C #" %>
<% @ Register Assembly = "fredck. fckeditorv2" namespace = "fredck. fckeditorv2" tagprefix = "fckeditorv2" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> Sample page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Fckeditorv2: FCKeditor id = "fckeditor1" runat = "server">
</Fckeditorv2: FCKeditor>
<Div>
</Div>
<Input type = "Submit" value = "Submit" runat = "server"/>
</Form>
</Body>
</Html>

Default. aspx. CS->

Empty

Upload set->

fckeditor2.6.3 has enabled authorized connections to upload and browse files in fckconfig. js by default, but all connections are set to unauthorized by default. Modify Editor/filemanager/connector/aspx/config. ascx.

private bool checkauthentication ()
{< br> // warning: do not simply return "true ". by doing so, you are allowing
// "anyone" to upload and list the files in your server. you must implement
// some kind of session validation here. even something very simple as
// return (session ["isauthorized"]! = NULL & (bool) session ["isauthorized"] = true );
// Where session ["isauthorized"] is set to "true" as soon as the
// user logs in your system.

Return true;
}
Find the checkauthentication method. By default, false is returned. Change it to true. You can also select the return value of permission Detection Based on logon conditions.

Now, the upload settings are complete!

The following describes how to optimize the upload settings:

1. There are two methods to upload FCKeditor: quick and non-quick.
You can click browse server to upload files in the Browse server window. This type of upload is automatically uploaded to the corresponding directory based on the type of the file to be uploaded, and the sample files are automatically uploaded to uploadfiles/image (uploadfiles are specified by the user );
You can use Quick Mode to upload files on the upload tab. This type of upload directly uploads files to the upload root directory uploadfiles. (Uploadfiles is specified by the user ).
However, I personally think that the bad part of quick upload is that all uploaded files are stored in the root directory regardless of the type, which is messy. Therefore, you need to store both upload methods in the corresponding folder according to the type.

Modification method:

Method 1: Modify filemanager/connectors/aspx/config. ascx

Typeconfig ["file"]. allowedextensions = new string [] {"7z", "AIFF", "ASF", "Avi", "BMP", "CSV", "Doc", "FLA ", "FLV", "GIF", "GZ", "gzip", "Jpeg", "jpg", "mid", "mov", "MP3", "MP4 ", "MPC", "MPEG", "MPG", "ODS", "ODT", "pdf", "PNG", "ppt", "pxd", "QT ", "Ram", "RAR", "RM", "RMI", "rmvb", "rtf", "SDC", "sitd", "SWF", "SXC ", "Sxw", "tar", "tgz", "TIF", "tiff", "TXT", "sealing", "WAV", "WMA", "WMV ", "xls", "XML", "Zip "};
Typeconfig ["file"]. deniedextensions = new string [] {};
Typeconfig ["file"]. filespath = "% userfilespath % file /";
Typeconfig ["file"]. filesabsolutepath = (userfilesabsolutepath = ""? "": "% Userfilesabsolutepath % file /");
Typeconfig ["file"]. quickuploadpath = "% userfilespath % file /";
Typeconfig ["file"]. quickuploadabsolutepath = (userfilesabsolutepath = ""? "": "% Userfilesabsolutepath % ");
Change the value of typeconfig ["file"]. quickuploadpath to the same value as typeconfig ["file"]. filespath = "% userfilespath % file /";

Method 2: Modify FCKeditor. net_2.6.3Source code(Troublesome)

(1) decompress fckeditor.net_2.6.3.zip, open the decompressed project, and modify filebrowser/fileworkerbase. CS.

Protected string servermapfolder (string resourcetype, string folderpath, bool isquickupload)
{
Typeconfig = This. config. typeconfig [resourcetype];

// Get the resource type directory.
-------------------*/
// String sresourcetypepath = isquickupload? Typeconfig. getquickuploaddirectory (): typeconfig. getfilesdirectory ();
/*------------------------------------*/
/* ----------- Modified -------------------*/
String sresourcetypepath = typeconfig. getfilesdirectory ();
/*------------------------------------*/
// Ensure that the directory exists.
Util. createdirectory (sresourcetypepath );

// Return the resource type directory combined with the required path.
Return System. Io. Path. Combine (sresourcetypepath, folderpath. trimstart ('/'));
}
As shown aboveCode, Whether isquickupload is true or false, the upload path (typeconfig. getfilesdirectory () is obtained in non-quick upload mode ()).
(2). Modify fckconfig. js

fckconfig. linkbrowser = true;
fckconfig. linkbrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Connector = '+ encodeuricomponent (fckconfig. basepath + 'filemanager/ORS ors/'+ _ filebrowserlanguage +'/connector. '+ _ filebrowserextension);
fckconfig. linkbrowser1_wwidth = fckconfig. screenwidth * 0.7; // 70%
fckconfig. linkbrowserwindowheight = fckconfig. screenheight * 0.7; // 70%

Fckconfig. imagebrowser = true;
Fckconfig. imagebrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Image & connector = '+ encodeuricomponent (fckconfig. basepath + 'filemanager/connectors/' + _ filebrowserlanguage + '/connector.' + _ filebrowserextension );
Fckconfig. imagebrowser1_wwidth = fckconfig. screenwidth * 0.7; // 70%;
Fckconfig. imagebrowserwindowheight = fckconfig. screenheight * 0.7; // 70%;

Fckconfig. flashbrowser = true;
Fckconfig. flashbrowserurl = fckconfig. basepath + 'filemanager/Browser/default/browser.html? Type = flash & connector = '+ encodeuricomponent (fckconfig. basepath + 'filemanager/connectors/' + _ filebrowserlanguage + '/connector.' + _ filebrowserextension );
Fckconfig. flashbrowser1_wwidth = fckconfig. screenwidth * 0.7; // 70%;
Fckconfig. flashbrowserwindowheight = fckconfig. screenheight * 0.7; // 70%;

fckconfig. linkupload = true;
fckconfig. linkuploadurl = fckconfig. basepath + 'filemanager/connectors/'+ _ quickuploadlanguage +'/upload. '+ _ quickuploadextension + '? Type = FILE';
// fckconfig. linkuploadallowedextensions = ""; // empty for all
fckconfig. linkuploadallowedextensions = ". (7z | AIFF | ASF | Avi | BMP | CSV | Doc | FLA | FLV | GIF | GZ | gzip | JPEG | JPG | mid | mov | MP3 | MP4 | MCM | MPEG | MPG | ODS | ODT | PDF | PNG | PPT | pxd | QT | Ram | RAR | RM | RMI | rmvb | RTF | SDC | sitd | SWF | SXC | Sxw | tar | tgz | TIF | tiff | TXT | ASD | WAV | WMA | WMV | XLS | XML | zip) $ "; // empty for all
fckconfig. linkuploaddeniedextensions = ""; // empty for no one

fckconfig. imageupload = true;
fckconfig. imageuploadurl = fckconfig. basepath + 'filemanager/connectors/'+ _ quickuploadlanguage +'/upload. '+ _ quickuploadextension + '? Type = image';
fckconfig. imageuploadallowedextensions = ". (JPG | GIF | JPEG | PNG | BMP) $ "; // empty for all
fckconfig. imageuploaddeniedextensions = ""; // empty for no one

fckconfig. flashupload = true;
fckconfig. flashuploadurl = fckconfig. basepath + 'filemanager/connectors/'+ _ quickuploadlanguage +'/upload. '+ _ quickuploadextension + '? Type = flash ';
fckconfig. flashuploadallowedextensions = ". (SwF | FLV) $ "; // empty for all
fckconfig. flashuploaddeniedextensions = ""; // empty for no one

You can see that there are two sets: browsing (linkbrowser, imagebrowser, and flashbrowser) and uploading (linkupload, imageupload, and flashupload ). We made the following changes:
Code
/* ------- Before modification ------------*/
Fckconfig. linkuploadurl = fckconfig. basepath + 'filemanager/connectors/'+ _ quickuploadlanguage +'/upload. '+ _ quickuploadextension;
/* ------- Modified -----------*/
Fckconfig. linkuploadurl = fckconfig. basepath + 'filemanager/connectors/'+ _ quickuploadlanguage +'/upload. '+ _ quickuploadextension + '? Type = FILE ';

Type = file is added at the end, so that the files uploaded by Adding links are uploaded to the file directory.
You can also modify fckconfig. linkbrowserurl and add type = file. In this way, you can only browse files and folders in the file directory when you click "Browse server" in the Add link. You can see that by default, only the image and flash directories can be viewed. If you remove type = image and type = flash, you can browse and upload all the directories under the root directory.

Now, the upload settings are complete. Of course, you can also make further settings for the upload, such as: randomly generate the file name; upload directory to year/month/; upload images with watermarks will be pasted later.

-------------------------------------------Note:--------------------------------------------------------------------------------

After dragging the fck control to the page, you must check a property of the control: basepath;

Because the fck decompression file is usually put under the project root directory, the basepath value should be changed ~ /FCKeditor/

    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.