The online editor FCKeditor has many advantages. For example, it is applicable to multiple development language Environments and features are free and open-source. It can be expanded as required.
You can download the latest source code from the official website.The latest official message FCKeditor has changed its name to ckeditor. The latest version is ckeditor. Net 3.5.3.
This article provides the following functions: add the watermark feature when uploading images using the editor.
How can I set up the FCKeditor editor on my website? I will not mention it. By default, you have set up and are familiar with the internal structure of FCKeditor.
When downloading the FCKeditor editor. net version, you must also download a source code package, which contains some function classes, and compiled DLL files, stored in the binfile. What we need to do is to modify the source code and re-compile the source code, generate a new DLL and replace it with your website.
I am using (the source code version is FCKeditor. net_2.5, And the editor file version is fckeditor_2.6.3)
Use vs2008 to open the fredck. fckeditorv2.csproj file under the Code root directory. After the file tree is expanded, find the fileworkerbase. CS file in the filebrowser folder and modify it.
We need to modify the fileupload method function in the fileworkerbase class.
Make preparations before reading the code.
Watermark is created on your website. config File, used to store some website configuration information, such as the watermark type (text type, image type), whether to add a watermark, text Content of text watermarks and other important configuration information unrelated to this article.
Therefore, the following code reads the configuration information.
Find the ofile. saveas (sfilepath); statement in the fileupload method. Add
Try
{
Dataset configds = new dataset ();
Configds. readxml (server. mappath ("~ /Config/watermark. config "));
Datatable configdt = configds. Tables [0];
If (configdt. Rows [0] ["watermarkstatus"]. tostring () = "1 ")
{
Image IMG = image. fromfile (sfilepath );
If (configdt. Rows [0] ["watermarktype"]. tostring () = "0 ")
{
Graphics G = graphics. fromimage (IMG );
G. drawimage (IMG, 0, 0, IMG. Width, IMG. Height );
Font F = new font (" 文 ", 40 );
Brush B = new solidbrush (color. White );
String addtext = configdt. Rows [0] ["watermarktext"]. tostring ();
G. drawstring (addtext, F, B, IMG. Width-174, IMG. Height-40 );
G. Dispose ();
}
If (configdt. Rows [0] ["watermarktype"]. tostring () = "1 ")
{
System. Drawing. Image copyimage = system. Drawing. image. fromfile (server. mappath ("~ /Watermark/watermark.gif "));
Graphics G = graphics. fromimage (IMG );
G. drawimage (copyimage, new rectangle (IMG. width-copyimage. width, IMG. height-copyimage. height, copyimage. width, copyimage. height), 0, 0, copyimage. width, copyimage. height, graphicsunit. pixel );
G. Dispose ();
}
Sfilename = system. Io. Path. getfilenamewithoutextension (ofile. filename );
String newpath = sfilename + "_" + datetime. Now. tostring ("yymmddhhmmss") + "." + sextension;
Newpath = system. Io. Path. Combine (sserverdir, newpath );
Sfilename = newpath;
IMG. Save (newpath );
IMG. Dispose ();
If (file. exists (sfilepath ))
{
File. Delete (sfilepath );
}
}
}
Catch
{
This. sendfileuploadresponse (808, isquickupload );
}
Note that you must create a config folder in the root directory of your site and store watermark. config in it,
The following fields must appear in watermark. config:
<Watermarkstatus> 0 </watermarkstatus> <! -- 0: add by default; 1: do not add -->
<Watermarktype> 1 </watermarktype> <! -- 0: Text watermark; 1: Image Watermark -->
<Watermarktext> ABCD </watermarktext>
<Watermarkpic> watermark.gif </watermarkpic>
Download the entire source code project package as follows:
/Files/CGLI/fredck.fckeditorv2.rar