tinymce.PluginManager.add("upfile", function (e) {
var t = e.settings;
e.addCommand("InsertUpFile", function () {
e.windowManager.open({
title: "上传图片",
width:parseInt(e.getParam("plugin_upfile_width", "300"), 10),
height: parseInt(e.getParam("plugin_upfile_height", "100"), 10),
html: '<div style="margin:10px"><select name="filepath"><option value="product">产品图片</option><option value="friendship">友情链接</option><option value="decorate">装修图片</option><option value="other">其他</option></select><br /><br /><input id="TinymcefileToUpload" type="file" name="TinymcefileToUpload" class="input"></div>',
buttons: {
text: "上传",
onclick: function () {
$.ajaxFileUpload
(
{
url: '/Admin/Index/UpFile?Path=' + $("select[name='filepath']").val(),//修改成您的地址就可以了
secureuri: false,
fileElementId: 'TinymcefileToUpload',
dataType: 'json',
beforeSend: function () {
$("#loading").show();
},
complete: function () {
$("#loading").hide();
},
success: function (data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
e.execCommand("mceInsertContent", !1, "<img src=" + data.msg + ">");
}
}
},
error: function (data, status, e) {
alert(data);
alert(e);
}
}
)
this.parent().parent().close();
}
}
})
}), e.addButton("upfile", {
icon: "image",
tooltip: "上传图片",
cmd: "InsertUpFile"
}), e.addMenuItem("upfile", {
icon: "image",
text: "上传图片",
cmd: "InsertUpFile",
context: "insert"
});
});
需要引用"ajaxfileupload"jquery上传文件插件。