【问题标题】:Tinymce image upload php plugin or somethingTinymce图片上传php插件什么的
【发布时间】:2014-06-18 22:28:00
【问题描述】:

我想在本地上传图片并在 textarea 中显示...有没有免费的插件,或者你能解释一下如何写一个吗?

我有这段代码:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    //width: 600,
    height: 300,
    file_browser_callback: function(field_name, url, type, win) {
        if(type=='image') $('.slike').click();
    },
    plugins: [
         "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
         "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
         "save table contextmenu directionality emoticons template paste textcolor ",
   ],
   content_css: "css/content.css",
   toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons", 
   style_formats: [
        {title: 'Bold text', inline: 'b'},
        {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
        {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
        {title: 'Example 1', inline: 'span', classes: 'example1'},
        {title: 'Example 2', inline: 'span', classes: 'example2'},
        {title: 'Table styles'},
        {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ],
 }); 
</script>

正文中的这段代码:

<form id='my_form' action='' method='POST' enctype="multipart/form-data">
        Title:<br/>
        <input type='text' name='title'/><br/><br/>
        Content:<br/>
         <textarea id="elm1" name="area"></textarea>        
        <br/>
        <input class='slike' name="image[]" multiple="multiple" type="file">
        <input type='submit' name='submit' value='Ok!'/>
    </form>

【问题讨论】:

    标签: javascript php image upload tinymce


    【解决方案1】:

    几周前我遇到了同样的问题。

    首先重要的是要注意tinymce textarea 会像网络浏览器一样显示图像和元素,因此您必须为href 属性图像标签输入正确的路径(外部发布的url 或本地url)。

    一旦您确定了 url,您将更改您的配置以避免 tinyMce 控件从您的代码中删除图像标签。我通过这种配置得到了这一点(使用绝对路径):

    tinyMCE.init({
        ...
        //your initialization rules
        ...
        // Drop lists for link/image/media/template dialogs
        template_external_list_url : 'lists/template_list.js',
        external_link_list_url     : 'lists/link_list.js',
        external_image_list_url    : 'lists/image_list.js',
        media_external_list_url    : 'lists/media_list.js',
        relative_urls              : false,
        remove_script_host         : false,
        convert_urls               : true,
        extended_valid_elements    : 'iframe[src|frameborder|style|scrolling|class|width|height|name|align]'
        });
    

    希望这段代码对你有帮助!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-08
      • 2015-11-15
      • 2020-12-19
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 2018-11-01
      • 1970-01-01
      相关资源
      最近更新 更多