【问题标题】:Invalid File Extension while uploading files in CKFINDER with asp.net使用 asp.net 在 CKFINDER 中上传文件时文件扩展名无效
【发布时间】:2014-04-06 00:49:16
【问题描述】:

我在我的 asp.net 项目中使用 CKFinder 2.4.1.2663 和 CKEditor 3.6.4.0。我可以上传图片,但是当我尝试上传任何文件(如 doc、xls 或 pdf)并单击将其发送到服务器按钮时,它会显示此错误:文件扩展名无效。

在我后面的代码中我写了这个:

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

并且在 Config.ascx 我已经更改了这段代码

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;
}

我正在像这样使用我的 aspx 中的控件

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

我必须将 CKFinder 用于图像和任何类型的文件扩展名。我哪里做错了?

【问题讨论】:

标签: c# asp.net ckeditor fckeditor ckfinder


【解决方案1】:

从外观上我可以看到 Config.ascx

中不允许使用 doc 和 xls 文件扩展名

默认情况下,CKFINDER WINDOW 中的根文件夹是图像,而在 Config.ascx 文件中,这些文件扩展名 (doc,xls) 不包含在图像文件夹的 ResourceType 中。

所以为了你摆脱这个错误,打开 Config.ascx 文件并将你想要的扩展名(doc,xls)添加到 baseUrl“图像”,像这样并添加

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

注意:不要更改任何内容,只需添加以逗号分隔的扩展名即可。

我知道这会解决你的问题,因为这对我来说是个问题,我通过这种方式解决了它。但如果你不介意你可以粘贴完整的 config.ascx 文件,我直接更新然后你复制并将其粘贴到您的系统上并运行它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 2015-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多