FCKeditor ASP. NET attachment upload Research

Source: Internet
Author: User
Tags file url

1. Install
There is not much to say about installation. Except for the general compressed package, Asp.. Net FCKeditor has another FCKeditor. net download package, which has a solution of Visual Studio, and a fredck in Bin/release. the fckeditorv2.dll file can be directly copied to your asp.. Net project.

2. Attachment upload Process
On the editing page, click link or image to open a modal dialog box. Select a local file and upload it.
This dialog box is FCKeditor/Editor/dialog/fck_image.htmlor fck_link.html.

JS in the dialog boxCodeIn the fck_image and fck_link directories, they also call common/fck_dialog_common.js

The above are all about the client.

There is a lonely upload under FCKeditor/Editor/filemanager/upload/Aspx. aspx contains only one sentence except comments. Its code behind code is in the previous ASP. net download package uploader. CS, which has been compiled into fredck. fckeditorv2.dll.

3. Modify uploader. CS
3.1 modify the unique line of code on upload. aspx.

Original version: <% @ page autoeventwireup = "false" inherits = "fredck. fckeditorv2.uploader" Language = "C #" %>
Changed to: <% @ page autoeventwireup = "false" codefile = "Upload. aspx. cs" inherits = "fckupload" Language = "C #" %>

In this way, upload. aspx will not go to fredck. fckeditorv2.dll to find its own behind code, but by its side.

3.2 extract uploader. CS from the FCKeditor. Net Package and put it together with upload. aspx in the FCKeditor directory of your asp. Net project. In this way, uploader. CS becomes part of your project and is under your control.

Open uploader. CS, and the code is not complicated.

First, you should add your own authentication.
Then, httppostedfile ofile = request. Files ["newfile"];, to obtain the file to be uploaded, The FCKeditor client should only upload one file at a time, so you do not have to consider multiple simultaneous uploads.

Get the file size, ofile. contentlength.
Get the file name, httpcontext. Current. Request. Files [0]. filename,
To check the suffix, system. Io. Path. getextension (filename );

Save, ofile. saveas (sfilepath); the file name and path are completely under your control.

Finally, send the error code back through sendresults. If the upload is successful, you can send 0, followed by the file name and File URL.

3.3 Client
If you are interested, you can study and modify the Js of the client.

4. Deployment
Decompress the FCKeditor. Net Package, open solution, delete uploader. CS, and re-compile fredck. fckeditorv2.dll. The new dll will be a little smaller. Here I will change it from 36k to 32 K. (Be sure to compile it into the release version ).

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