FCKeditor 2.6.3 (ASP) -- add the size limit of uploaded files

Source: Internet
Author: User
Tags case statement

The FCKeditor was modified in February. I was too lazy to write it until now.

FCKeditor is indeed a powerful online editor with user-friendly design and compatibility with multiple browsers, such as IE and Firefox (I tested both ). For the modification of FCKeditor, I mainly modified the Add button, restrict the upload size, and filter ASP Trojans. Let's talk about how to modify the upload size limit today.

You can modify the upload size in three ways:

(1) define the maximum value that can be uploaded.

This is modified in FCKeditor \ editor \ filemanager \ connectors \ ASP \ config. asp. Add the following code at the end of the file:

Dim linkuploadlimit, imageuploadlimit, flashuploadlimit, attachuploadlimit, mediauploadlimit
Dim linkuploadmaxsize, imageuploadmaxsize, flashuploadmaxsize, attachuploadmaxsize, mediauploadmaxsize
'Size limit of linked files
Linkuploadlimit = true
Linkuploadmaxsize = 102400
'Image upload size limit
Imageuploadlimit = true
Imageuploadmaxsize = 2048
'Flash upload size limit
Flashuploadlimit = true
Flash uploadmaxsize = 2048
'Maximum upload size of multimedia files
Mediauploadlimit = true
Mediauploadmaxsize = 204800
'Attachment upload size limit
Attachuploadlimit = true
Attachuploadmaxsize = 20480

FCKeditor divides the uploaded files into link, image, Flash, and media types based on different upload methods (attach type is added by me), which correspond to the upload of buttons on the FCKeditor toolbar respectively, for example, the link corresponds to the File Uploaded when the hyperlink button is used to create the hyperlink. Therefore, two variables are defined for each type. One variable is used to set whether to enable the upload restriction. The other is the maximum upload value, in K.

(2) Determine whether the number of uploaded files exceeds the limit.

This is modified in FCKeditor \ editor \ filemanager \ connectors \ ASP \ commands. asp.

Add the following code after the statement soriginalfilename = sfilename after row 3:

'The file size upload limit is added here.
Dim dfilesize, uploadlimitmaxsize, isuploadlimit, islimitok

'UNIT: keep consistent with the set value. Set the value to K.
Dfilesize = ouploader. File ("newfile"). Size/1024.
'Depending on the type of the upload, the set value is used to determine whether to allow upload and the maximum value allowed for upload.
Select case sresourcetype
Case "file"
Isuploadlimit = linkuploadlimit
Uploadlimitmaxsize = linkuploadmaxsize
Case "image"
Isuploadlimit = imageuploadlimit
Uploadlimitmaxsize = imageuploadmaxsize
Case "Flash"
Isuploadlimit = flashuploadlimit
Uploadlimitmaxsize = flashuploadmaxsize
Case "Media"
Isuploadlimit = mediauploadlimit
Uploadlimitmaxsize = mediauploadmaxsize
Case "Attach"
Isuploadlimit = attachuploadlimit
Uploadlimitmaxsize = attachuploadmaxsize
'Case "Media"
Case else
'Upload is restricted by default. The maximum size is 1 MB.
Isuploadlimit = true
Upload limitmaxsize = 102400
End select

'------------- End of reading and uploading settings -----------------------
'Determine whether the file to be uploaded exceeds the set value. If islimitok is used to determine islimitok = true, the file cannot be uploaded.
Islimitok = false
If isuploadlimit then
If dfilesize> uploadlimitmaxsize then
Islimitok = true
Serrornumber = "204"
End if
End if

'-------------- Judge the end. If the file to be uploaded exceeds the set value, the error code is set to 204 -----

Modify do while... after 172 rows ...... Loop statement

Change do while (true) to do while (not islimitok)

(3) define the client error message.

The client error message is modified in the JS file in the folder corresponding to each type of upload (such as link and image.

Link: modify it in fck_link.js under FCKeditor \ editor \ dialog \ fck_link \.

Modify switch… in function onuploadcompleted (errornumber, fileurl, filename, custommsg... Case statement

That is, after the following statements

Case 203:
Alert ("security error. You probably don't have enough permissions to upload. Please check your server .");
Return;

Add the following code:

Case 204:
Alert ('the file size exceeds the set value and cannot be uploaded! ');
Return;

You can modify other types in the same way.

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.