在TinyMCE中上传文件

时间:2018-04-20 13:28:36

标签: asp.net tinymce

在ASP.NET MVC中,我使用的是TinyMCE 4.7.8(2018-02-26)。我想上传一个Pdf / Doc / Excel文件,并在编辑器HTML中为它添加一个锚点。我能够上传图像并获取上传的网址,以便在编辑器中添加图像,这样可以正常工作。

我正在寻找两件事的答案a)链接插件是将pdf和doc上传到系统的正确方法,因为我没有在社区版中找到任何特定的文件处理插件! b)在我的方法filePicker中,我正在创建动态html来处理发布的文件,再次,这种方法只是在TinyMCE中处理文件类型的任何方法吗?

tinymce.init({
    selector: ".TinyMCEEditor",
    branding: false,
    height: 500,
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview | forecolor backcolor emoticons",
    file_browser_callback_types: 'file image',
    automatic_uploads: true,
    images_upload_url: '/Content/UploadContentImg',
    file_picker_types: 'file image',
    file_picker_callback: function(callback, value, meta) {
        debugger;
        // Provide image and alt text for the image dialog
        if (meta.filetype == 'image') {
            imageFilePicker(callback, value, meta);
        }

        // Provide file and text for the link dialog
        if (meta.filetype == 'file') {
            filePicker(callback, value, meta);
            //callback('mypage.html', { text: 'My text' });
        }

        // Provide alternative source and posted for the media dialog
        if (meta.filetype == 'media') {
            //callback('movie.mp4', { source2: 'alt.ogg', poster: 'image.jpg' });
        }
    },
    templates: [{
            title: 'Test template 1',
            content: 'Test 1'
        },
        {
            title: 'Test template 2',
            content: 'Test 2'
        }
    ]
});


function imageFilePicker(callback, value, meta) {

};

function filePicker(callback, value, meta) {

    var input = document.createElement('input');
    input.setAttribute('type', 'file');

    //input.setAttribute('accept', 'image/*');

    input.click();

    debugger;
};

0 个答案:

没有答案