如何在CKeditor中添加音频标签

时间:2017-04-29 08:58:04

标签: c# asp.net ckeditor

我添加了html5audio插件并能够获取上传按钮,但是如何将上传的文件发送到服务器。

这是我的插件代码

{
        id: 'Upload',
        hidden: false,
        filebrowser: 'uploadButton',
        label: editor.lang.html5audio.upload,
        elements: [ {
            type: 'file',
            id: 'upload',
            label: editor.lang.html5audio.btnUpload,
            style: 'height:40px',
            size: 38
        },
        {
            type: 'fileButton',
            id: 'uploadButton',
            filebrowser: 'info:url',
            label: editor.lang.html5audio.btnUpload,
            'for': [ 'Upload', 'upload' ]
        } ]
    },

1 个答案:

答案 0 :(得分:1)

您需要创建handler以将其上传的文件发送到服务器

<强>处理程序

<%@ WebHandler Language="C#" Class="Upload" %>

using System;
using System.Web;

public class Upload : IHttpHandler {

    public void ProcessRequest (HttpContext context) {

        HttpPostedFile uploads = context.Request.Files["upload"];
        string CKEditorFuncNum = context.Request["CKEditorFuncNum"];
         string file = System.IO.Path.GetFileName(uploads.FileName);
        uploads.SaveAs(context.Server.MapPath(".") + "\\Audio\\" + file);

      //  string url =  "/ckeditor/Images/" + file;
        string url =  System.Configuration.ConfigurationManager.AppSettings["CKEditorAudioUrl"].ToString() + file;
        context.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>");
        context.Response.End();  

    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

在您的配置文件中,您需要更新

config.filebrowserUploadUrl = 'Path to your Handler;