FCKeditor asp.net upload Attachment Research _ Web Editor

Source: Internet
Author: User
Tags file size file url visual studio
1, installation
Installation is not much said, in addition to the general compression package, ASP. NET version of FCKeditor has another fckeditor.net download package, which has a Visual Studio solution,bin/ There is a FredCK.FCKeditorV2.dll file in release that you can copy directly into the bin folder of your ASP.net project.

2, attachment upload process
FCKeditor opens a modal dialog box by clicking the link or Picture button in the edit interface, and then uploading the local file in it.
This dialog box is fckeditor/editor/dialog/fck_image.html or fck_link.html.

The JS code for the dialog box is in the Fck_image and Fck_link directories, and they also call Common/fck_dialog_common.js

These are the client's business.

Under the fckeditor/editor/filemanager/upload/aspx there is a lonely upload.aspx, inside in addition to the annotation only a word, its code behind The code is in the front of the asp.net download package Uploader.cs, has been compiled into the FredCK.FCKeditorV2.dll.

3. Modify Uploader.cs
3.1 Modify the only line of code on the upload.aspx.

Original:<%@ page autoeventwireup= "false" inherits= "FredCK.FCKeditorV2.Uploader" language= "C #"% >
Modify to:<% @ Page autoeventwireup= "false" codefile= "Upload.aspx.cs" inherits= "Fckupload" language= "C #"% >

In this way, upload.aspx no longer go to FredCK.FCKeditorV2.dll to find their own behind code, but to find their side.

3.2 Extract the Uploader.cs from the Fckeditor.net compression package and place it in the FCKeditor directory of your ASP.net project and upload.aspx. In this way, Uploader.cs is a part of your project, completely under your control.

Open Uploader.cs, the code inside is not complicated.

First, you should add your own authentication.
Then, httppostedfile ofile = request.files["NewFile"];, to get uploaded files, the FCKeditor customer should be uploading only one at a time, without having to consider multiple simultaneous uploads.

Get file size, ofile.contentlength.
Get filename, httpcontext.current.request.files[0]. FileName,
To check the suffix, System.IO.Path.GetExtension (FileName);

Save it, Ofile.saveas (sfilepath); The filename and path are completely in your control.

Finally, the error code sent back through the Sendresults, if uploaded successfully, you can send 0, then the filename and file URL.

3.3 Client
If you are interested, you can study the changes to the client's JS.

4. Deployment
Decompression Fckeditor.net Compression package, open the inside of the solution, delete the Uploader.cs, recompile FredCK.FCKeditorV2.dll, the new DLL will be smaller, I am here from 36K to 32K. (Note that you want to compile to release version).

Finally, replace the old DLL in your own project with the new DLL.
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.