我们如何使用codeigniter
在js文件中使用基本URLCKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
// ...
config.filebrowserBrowseUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=flash';
// ...
};
在这里使用base_url
config.filebrowserImageBrowseUrl = base_url().'/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
答案 0 :(得分:1)
你不能像这样在javascript代码中调用php函数。
如果你的javascript在你的视图中,你就可以这样做
config.filebrowserImageBrowseUrl = <?php echo base_url(); ?>.'/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
但如果您的javascript代码位于单独的.js文件中,请使用javascript
config.filebrowserImageBrowseUrl = location.protocol + '//' + location.host + '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
最终,您可以在view.php中声明
<script>
var baseUrl = "<?php echo base_url(); ?>";
</script>
并在你的js中调用它
config.filebrowserImageBrowseUrl = baseUrl + '/codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
答案 1 :(得分:0)
你不能在这样的javascript中使用PHP。
尝试<?=base_url('codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images)?>
或<?php echo base_url('codeigniter/kpminerals/support/editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images'); ?>
你的config.php中是/ codeigniter /你的基本网址的一部分吗?如果有,请将其从上面删除。
答案 2 :(得分:0)
这是js文件中的写作
var base_url = window.location;
// ...
config.filebrowserBrowseUrl = base_url+'editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = base_url+'editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = base_url+'editor/ckeditor/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = base_url+'editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = base_url+'editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = base_url+'editor/ckeditor/kcfinder/upload.php?opener=ckeditor&type=flash';
// ...