问题
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