Php 如何使用Tinymces文本编辑器从计算机上载图像?

Php 如何使用Tinymces文本编辑器从计算机上载图像?,php,ajax,tinymce,codeigniter-2,tinymce-4,Php,Ajax,Tinymce,Codeigniter 2,Tinymce 4,Tinymce 亲爱的: 我目前在网页设计中使用Tinymce文本编辑器,但它不适用于从计算机上传的图像。 下面是我从其他教程中复制的源代码,但我不知道当用户编辑或将一些图像插入我的数据库时如何修改或启用从计算机上载的图像 请检查并帮助 <script type="text/javascript"> tinymce.init({ selector: "textarea", theme: "modern",

Tinymce

亲爱的:

我目前在网页设计中使用Tinymce文本编辑器,但它不适用于从计算机上传的图像。 下面是我从其他教程中复制的源代码,但我不知道当用户编辑或将一些图像插入我的数据库时如何修改或启用从计算机上载的图像 请检查并帮助

<script type="text/javascript">
        tinymce.init({

            selector: "textarea",
            theme: "modern",
            width: "630",
            height: "auto",
            plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,paste,fullscreen,noneditable,contextmenu",
            theme_advanced_buttons1_add_before : "newdocument,separator",
            theme_advanced_buttons1_add : "fontselect,fontsizeselect",
            theme_advanced_buttons2_add : "separator,forecolor,backcolor,liststyle",
            theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,",
            theme_advanced_buttons3_add_before : "tablecontrols,separator",
            theme_advanced_buttons3_add : "flash,advhr,separator,fullscreen",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            extended_valid_elements : "hr[class|width|size|noshade]",
            file_browser_callback : "image",
            paste_use_dialog : false,
            theme_advanced_resizing : true,
            theme_advanced_resize_horizontal : true,
            apply_source_formatting : true,
            force_br_newlines : true,
            force_p_newlines : false,
            relative_urls : true,
            toolbar: "insertfile | image| responsivefilemanager| undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" || "print preview media | forecolor backcolor emoticons",
            plugins: "image",
            image_advtab:true,  
            image_list: [
                {title: 'My image 1', value: 'public_html/upload/'},
                {title: 'My image 2', value: 'public_html/upload/'}
            ]
            });
    </script>

tinymce.init({
选择器:“文本区域”,
主题:“现代”,
宽度:“630”,
高度:“自动”,
插件:“分页、样式、图层、表格、保存、advhr、advimage、advlink、情感、iespell、insertdatetime、预览、媒体、搜索替换、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、可视光标、不可中断、xhtmlxtras、模板、字数、advlist、自动保存、粘贴、全屏、不可编辑、上下文菜单”,
主题\u高级\u按钮1\u在“新建文档,分隔符”之前添加,
主题\高级\按钮1\添加:“fontselect,fontsizeselect”,
主题\高级\按钮2\添加:“分隔符、前景色、背景色、列表样式”,
主题\高级\按钮2 \在“剪切、复制、粘贴、粘贴文本、粘贴单词、分隔符”之前添加,
主题\u高级\u按钮3\u添加\u之前:“tablecontrols,separator”,
主题\u高级\u按钮3\u添加:“flash、advhr、分隔符、全屏”,
主题\高级\工具栏\位置:“顶部”,
主题\高级\工具栏\对齐:“左”,
扩展的|有效|元素:“hr[类别|宽度|大小|无阴影]”,
文件\浏览器\回调:“图像”,
粘贴使用对话框:false,
主题\u高级\u大小调整:正确,
主题\u高级\u调整大小\u水平:正确,
应用\u源\u格式:true,
force\u br\u新词:对,
force_p_新行:false,
相对URL:true,
工具栏:“插入文件|图像|响应文件管理器|撤消重做|样式选择|粗体斜体|对齐左对齐居中对齐右对齐对齐对齐对齐对齐|粗体numlist outdent缩进|链接图像”|“打印预览媒体|前景色背景表情”,
插件:“图像”,
图像\u advtab:正确,
图像列表:[
{title:'My image 1',value:'public_html/upload/'},
{title:'My image 2',value:'public_html/upload/'}
]
});
它可以与文本功能配合使用,但不适用于图像上传 示例:当我单击插入图像/编辑图像->弹出加载,然后单击图像图标选择图像,但它不显示任何内容

感谢您的帮助

您的“图像”是一个回调函数

tinyMCE.init({
    // General options
    mode : "textareas",
    theme : "advanced",

    //plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount",
    editor_selector : "tiny",
    plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,images,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

    // Theme options
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,images, cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,
});
function myFileBrowser (field_name, url, type, win) {

// alert("Field_Name: " + field_name + "nURL: " + url + "nType: " + type + "nWin: " + win); // debug/testing

/* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
   the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
   These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */

var cmsURL = window.location.toString();    // script URL - use an absolute path!
if (cmsURL.indexOf("?") < 0) {
    //add the type as the only query parameter
    cmsURL = cmsURL + "?type=" + type;
}
else {
    //add the type as an additional query parameter
    // (PHP session ID is now included if there is one at all)
    cmsURL = cmsURL + "&type=" + type;
}

tinyMCE.activeEditor.windowManager.open({
    file : cmsURL,
    title : 'My File Browser',
    width : 420,  // Your dimensions may differ - toy around with them!
    height : 400,
    resizable : "yes",
    inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
    close_previous : "no"
}, {
    window : win,
    input : field_name
});
return false;
}

参考资料:

你能把你的问题缩小到“它不起作用”以外的范围吗?有错误吗?您在教程中学习的任何示例在图像方面都没有达到预期效果?很抱歉,错过了“关于其他”功能,但当我单击“插入/编辑图像”而不是单击“图像”图标时,它不仅对图像上传有效,而且不会显示任何结果,也不会显示任何方式将图像插入到我的任务中。因此,如果我想上传图像功能我必须买这个选项,对吗?你必须定制插件和主题按钮是的,我一直在尝试阅读并找到调用它的方法,但我不能,因为它对我来说非常深刻。虽然像这样,我仍然致力于做它,你可以在他们的网站上找到更多细节,我在我的项目中使用它,我可以说我需要的是WYSIWYG编辑器谢谢Shen Siddhara和其他专家也谢谢
tinyMCE.init({
  theme : ...,
  mode: ...,

  file_browser_callback : 'myFileBrowser'
});