How to use FCKeditor for ASP

Source: Internet
Author: User
Tags file upload root directory

1. Default language

Open fckconfig.js file (relative FCKeditor folder, below), change the automatic detection language to not detect, change the default language to Simplified Chinese:
Program code
Fckconfig.autodetectlanguage = false;
Fckconfig.defaultlanguage = ' ZH-CN ';


2. Font list
Open fckconfig.js file, add the commonly used "XXFarEastFont-Arial" in the Font list _gb2312 ":

Program code
Fckconfig.fontnames = ' song body; bold; official script; italics _gb2312; Arial; Comic Sans MS; Courier New; Tahoma; Times New Roman; Verdana ';

3, File Upload
FCKeditor file Management program in the FileManager folder, but also divided into browse (browser) and upload (upload) two kinds. Browsing refers to browsing server files and optionally uploading local files to the server; upload refers to fast upload (quickupload), in the window of the "Upload" tab open is, with the UBB editor we use a bit similar, select the local file upload on the line.
That is, there is a file browsing in FCKeditor, there are two files uploaded, and some of these settings in a file, some in multiple files. More complex, more changes, we have a few small points to say.

① Open and close file browsing and uploading functions
There are three files with this switch has a relationship, a JS file, two are ASP files, the former closed after the interface does not appear related to the window or button, the latter closed after the relevant features are not available.
The first is the Fckconfig.js file, and the following is set to true and false to off.
File browsing and browsing in the upload function:

Program code
Fckconfig.linkbrowser = false;
Fckconfig.imagebrowser = false;
Fckconfig.flashbrowser = false;

Quick File Upload function:

Program code
Fckconfig.linkupload = true;
Fckconfig.imageupload = true;
Fckconfig.flashupload = true;

Second, set up two ASP files:
Editorfilemanagerbrowserdefaultconnectorsaspconfig.asp

Program code
configisenabled = False
Indicates file browsing shutdown

Editorfilemanageruploadaspconfig.asp

Program code
configisenabled = True
Indicates file fast upload Open

② file upload or browse path settings
Note that FCKeditor does not support virtual directories, all of your paths are absolute paths to the root directory of your Web site, which is not easy for developers who use virtual directories for local testing to publish to remote site directories. This is my case, the WinXP system can only be a site, only the virtual directory to represent different sites, in the local test well, before uploading to temporarily change this setting.
File browse path, open file editorfilemanagerbrowserdefaultconnectorsaspconfig.asp:

Program code
Configuserfilespath = "/attachments/"

Quick upload Path, open file editorfilemanageruploadaspconfig.asp:

Program code
Configuserfilespath = "/attachments/"

My file directory is below http://127.0.0.1/temp/, just follow the above settings. If you are testing this site locally in virtual directory xxx, you should set it to:

Program code
Configuserfilespath = "/127.0.0.1/temp/"


③ file Fast upload a source file bug
After the above settings, file browsing and browsing upload can be carried out smoothly, but you will find that "fast upload" can not be used. The phenomenon is that when you select a good local file, click on the "Upload to the Server" button after no response. This is due to a bug in the Fckconfig.js file.
Open fckconfig.js file, place Fckconfig.quickuploadlanguage typeface, replace into _quickuploadlanguage, replace three places altogether. The former is not defined on the use, so the error, according to the code intent should be the same as the value of the latter.

④ upload file name automatically renamed
FCKeditor does not support Chinese file names, so we want to change the name when the file is saved to the server. Because there are two places to upload, and the file is different, so two files should be changed at the same time, we first look at the fast upload file, open editorfilemanageruploadaspupload.asp, the file finally add the following function:

Program code
Public Function Getnewfilename ()
Dim rannum
Dim Dtnow
Dtnow=now ()
Randomize
Rannum=int (90*RND) +10
Getnewfilename=year (Dtnow) & Right ("0" & Month (Dtnow), 2) & Right ("0" & Day (Dtnow), 2) & Right ("0" ; Hour (Dtnow), 2 & Right ("0" & Minute (Dtnow), 2) & Right ("0" & Second (Dtnow), 2) & Rannum
End Function

We use the date of the year and the two-digit random number as the filename, so that both the file upload time can be resolved, nor is it easy to duplicate the name.
And then still this file, find:

Program code
' Get the uploaded file name.
sFileName = Ouploader.file ("NewFile"). Name

Change it to:

Program code
' Get the uploaded file name.
sFileName = Getnewfilename () & "." & Split (Ouploader.file ("NewFile"). Name, ".")

It says the files are uploaded quickly, and the file browsing is a change of another file (editorfilemanagerbrowserdefaultconnectorsaspcommands.asp), The method is the same as the one above: Add a function and modify one line of code.

4, in the ASP source program reference FCKeditor Editor
First insert the server-side include statement at the top of the ASP page:

Program code
<!--#include file= "fckeditor/fckeditor.asp"-->

Then add the following code inside the form:

Program code
' Define variables
Dim Ofckeditor
' Initialization of the class
Set ofckeditor = New FCKeditor
' Define path (default path:/fckeditor/)
Ofckeditor.basepath= "fckeditor/"
' Define the toolbar (default: Defaults)
ofckeditor.toolbarset= "Basic"
' Define width (default width: 100%)
Ofckeditor.width= "100%"
' Define height (default height: 200)
ofckeditor.height=350
' The initial value of the input box
Ofckeditor.value= "This is the sample text. "
' Create an input box named: Content
Ofckeditor.create "Content"

This creates an input box with a hidden name content in the form that can be used like any other form element, such as using the following code to get the value of the input box:

Program code
Dim content
Content=checkstr (Request.Form ("content")
above the input data is detected with CHECKSTR, if the original data contains single quotes or something, Then there will be an error updating the database.

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.