How to add audio tag to CKeditor

I added a plugin html5audio

and can get the Upload button, but how do I 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' ]
        } ]
    },

      

+2


source to share


1 answer


you need to create handler

to send uploaded files to 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;

      

+1


source







All Articles