How do I allow file upload on TinyMCE 4?

40 Views Asked by At

I'm working on a site which is a few years old and uses TinyMCE 4 (4.9.2). It has an image uploader, and I've been asked to add general file upload.

After reading the relevant manual page, I thought I only needed to add file_picker_types and file_picker_callback, and that this would turn the image picker into a file picker too, but this hasn't made any difference - the file uploader doesn't appear.

My TinyMCE instance is initialised like this:

<script>
    tinymce.init({
        branding: true,
        height: 500,
        selector:'#editor_area',
        menubar: false,
        toolbar: [
            'code | undo redo | cut copy paste | styleselect | bold italic underline removeformat | alignleft aligncenter alignright | charmap | bullist numlist | link image'
        ],
        plugins: ["advlist", "lists", "link", "autolink", "image", "charmap", "code"],
        document_base_url : "<?= FULL_BASE_URL ;?>",
        relative_urls : false,
        remove_script_host : false,
        file_picker_types: 'file image media',
        file_picker_callback: function(callback, value, meta) { alert('OK'); },
        images_reuse_filename: true,
        images_upload_base_path: "<?= FULL_BASE_PATH_USERFILES_IMG;?>",
        images_upload_url: "<?= FULL_BASE_URL ;?>/admin/uploads/uploadImage",
        images_upload_handler: function (blobInfo, success, failure) {
            ... function for uploading image ...
        },
    });
</script>

As I said, the image uploader works fine; I just can't get a file uploader to appear.

0

There are 0 best solutions below