首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在CKeditor中添加音频标记

如何在CKeditor中添加音频标记
EN

Stack Overflow用户
提问于 2017-04-29 08:58:03
回答 1查看 787关注 0票数 2

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

这是我的插件代码

代码语言:javascript
复制
{
        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' ]
        } ]
    },
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-29 09:19:52

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

Handler

代码语言:javascript
复制
<%@ 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文件中,需要更新

代码语言:javascript
复制
config.filebrowserUploadUrl = 'Path to your Handler;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43693699

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档