How to add the audio tag in the CKeditor

末鹿安然 提交于 2019-12-13 14:57:24

问题


I have added the html5audio plugin and able to get the Upload button , but how to send the uploaded file to the server.

Here is my plugin Code

{
        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:


you need to create handler to send ther uploaded files to the server

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

}

In your Config file you need to update

config.filebrowserUploadUrl = 'Path to your Handler;


来源:https://stackoverflow.com/questions/43693699/how-to-add-the-audio-tag-in-the-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!