简体   繁体   中英

Invalid File Extension while uploading files in CKFINDER with asp.net

I am using CKFinder 2.4.1.2663 and CKEditor 3.6.4.0 in my asp.net project. I am able to upload images but when I try to upload any files like doc, xls or pdf and click on send it to the server button, it shows this error: invalid file extension.

In my code behind i have written this:

protected override void OnLoad(EventArgs e)
{
    CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
    _FileBrowser.BasePath = "/ckfinder/";
    _FileBrowser.SetupCKEditor(CKEditor1);
}

and in Config.ascx i have changed this code

public override bool CheckAuthentication()
{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...
    //
    //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
    //
    // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
    // user logs on your system.
    return true;
}

I am using the control in my aspx like this

<CKEditor:CKEditorControl ID="CKEditor1" runat="server"></CKEditor:CKEditorControl>

I have to use CKFinder for images and any types of file extension. Where i am doing wrong?

From the look of things i can see that the doc and xls file extensions where not allowed in your Config.ascx

By default, in the CKFINDER WINDOW the root folder is images and in the Config.ascx file, these file extensions ( doc,xls ) were not included in the ResourceType for the images folder.

so for you to get rid of this ERROR , Open the Config.ascx file and add the extensions (doc,xls) you want to the baseUrl "images", something like this and add

'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,doc,xls

Note: Dont change anything just add the extensions separated by commas.

I know this will solve your problem, because it was an issue for me and i solved it doing it this way.But if you dont mind you can paste the complete config.ascx file and i do the direct update and you copy and paste it on your system and run it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM