CKEditor和CkFinder在PHP中工作正常,但不显示图像,闪存等 [英] CKEditor and CkFinder work fine in PHP but don't show images, flash etc

查看:422
本文介绍了CKEditor和CkFinder在PHP中工作正常,但不显示图像,闪存等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CKEditor和CKFinder。两个工作正常。当我浏览(或直接复制)一个图像(或闪存)到CKEditor,它显示在其中并插入到MySql数据库。



在将其插入MySql数据库后,我尝试在HTML表格中显示它,不显示它,并显示替代文本。



通过CKFinder浏览图像后的图像路径如下所示。

 < img alt =src =/ ckfinder / userfiles / images / 1243_SS_2502.jpgstyle =width:490px; height:618px; /> 

插入数据库的内容如下。

 & lt; img alt =& quot; \& amp; quot; \& amp; amp; data-cke-saved-src =& quot; \& quot; 

src =& quot; \& amp; quot; /ckfinder/userfiles/images/1243_SS_2502.jpg \& amp; quot;& st yle =&

quot; \& amp; quot; width:& amp; 490px; =& quot;& quot; height:=& quot;& quot; 618px; \& quot; = quot;& quot;& gt;

尝试使用 htmlentities() 仍然不工作。当使用JSTL / EL处理相同的JSP时,我不得不这样做。

 < c:out value = $ {str}default =找不到内容。 escapeXml =false/> 

escapeXml =false在EL中写的code> str 是一个 java.lang.String 持有Oracle clob 转换后的数据。



在PHP中解决问题的方法是什么? CKEditor和CKFinder对我都很好。






  $ ckeditor = new CKEditor ); 
$ ckeditor-> basePath ='ckeditor /';
$ ckeditor-> config ['filebrowserBrowseUrl'] ='ckfinder / ckfinder.html';
$ ckeditor-> config ['filebrowserImageBrowseUrl'] ='ckfinder / ckfinder.html?type = Images';
$ ckeditor-> config ['filebrowserFlashBrowseUrl'] ='ckfinder / ckfinder.html?type = Flash';
$ ckeditor-> config ['filebrowserUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Files';
$ ckeditor-> config ['filebrowserImageUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Images';
$ ckeditor-> config ['filebrowserFlashUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Flash';
$ ckeditor-> editor('description',$ ed_about_us);






编辑 / p>

 <?php include_once(Lock.php);?> 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title> Wagafashion< / title>

< link rel =stylesheethref =css / validationEngine.jquery.csstype =text / css/>
< link rel =stylesheethref =css / template.csstype =text / css/>
<! - < script type =text / javascriptlanguage =javascriptsrc =ckeditor / ckeditor.js>< / script>
< script src =js / jquery-1.6.min.jstype =text / javascript>< / script>
< script src =js / languages / jquery.validationEngine-en.jstype =text / javascriptcharset =utf-8>< / script&

< script src =js / jquery.validationEngine.jstype =text / javascriptcharset =utf-8>< / script>< script&
jQuery(document).ready(function(){
//将表单提交和字段绑定到验证引擎
jQuery(#dataForm)。validationEngine();
});
< / script>

< script language =javascripttype =text / javascript>
function deleteSingle(id)
{
var delId = confirm(关于我们的id为+ id +即将永久删除。\\\
\\\
Attention:永远不会撤消!\\\
\\\
Are you sure ... ???);
return(delId == true?true:false);
}

< / script>

< / head>

< body>
<?php
include_once(Connection.php);
include_once(ckeditor / ckeditor.php);
$ con = new Connection();
$ con> get_connection();

$ ed_about_us =;
$ flag = -1;
$ msg =;

if(isset($ _ POST ['btnSubmit']))
{
$ act = trim($ _ POST ['param_action']);
$ about_us = $_ POST ['cms_description'];

if($ act ==add)
{
$ res = $ con> get_data(select count(*)as cnt from cms);
$ cnt_cmt = mysql_result($ res,'cnt');

if($ cnt_cmt == 0)
{
$ flag = $ con> iud(insert into cms(about_us)values('。mysql_real_escape_string(urlencode ($ about_us))。'));
}
else
{
$ flag = $ con> iud(update cms set about_us ='。mysql_real_escape_string(urlencode($ about_us))。 );
}

if($ flag == 1)
{
$ msg =Insertion done successfully。
}
else if($ flag == 0)
{
$ msg =插入失败 - 原因:.mysql_errno()。:.mysql_error
}
}
else if($ act ==edit)
{
$ cms_id = $ _ POST ['cms_id'];
$ flag = $ con> iud(update cms set about_us ='。mysql_real_escape_string(urlencode($ about_us))。''where id =。$ cms_id。
if($ flag == 1)
{
$ msg =关于我们已经成功更新。
}
else if($ flag == 0)
{
$ msg =更新失败 - 原因:.mysql_errno()。:.mysql_error();
}
}
}
else if(isset($ _ GET ['ed_id']))
{
$ ed_res = $ con> get_data(select about_us from cms where id =。$ _ GET ['ed_id']。);

while($ row = mysql_fetch_assoc($ ed_res))
{
$ ed_about_us = $ row ['about_us'];
}
}
else if(isset($ _ GET ['del_id']))
{
$ flag = $ con> iud set about_us =''where id =。$ _ GET ['del_id']);
if($ flag == 1)
{
$ msg =关于我们已成功删除。
}
else if($ flag == 0)
{
$ msg =无法删除 - 原因:.mysql_errno()。:.mysql_error ;
}
}
else if(isset($ _ POST ['btnDelete']))
{
$ set_del = $ _ POST ['setDel'];
$ flag = $ con> iud(update cms set about_us =''where id in($ set_del));
$ size = sizeof(split(,,$ set_del));

if($ flag == 1)
{
if($ size == 1)
{
$ msg =1 row deleted。 ;
}
else
{
$ msg = $ size。rows deleted。
}
}
else if($ flag == 0)
{
$ msg =无法执行删除 - 原因:.mysql_errno()。 :.mysql_error();
}
}
?>

<?php include(tamplate / Template1.php);?>
< h2>关于我们< / h2>
<?php include(tamplate / NewTemplate.php);?>

<?php
if($ flag == 1)
{
echo< p&
?>
<! - [if!IE]>启动系统消息<![endif] - >
< ul class =system_messages>
< li class =green>< span class =ico>< / span>< strong class =system_title><?php echo $ msg; ?>< / strong>< / li>
< / ul>
<! - [if!IE]> end system messages<![endif] - >
<?php
echo< / p>;
}
else if($ flag == 0)
{
echo< p>;
?>
<! - [if!IE]>启动系统消息<![endif] - >
< ul class =system_messages>
< li class =red>< span class =ico>< / span>< strong class =system_title><?php echo $ msg; ?>< / strong>< / li>
< / ul>
<! - [if!IE]> end system messages<![endif] - >
<?php
echo< / p>;
}
?>
< img alt = \\src =/ ckfinder / userfiles / images / 1243_SS_2502.jpgstyle = \width:490px; height:618px; \/&
<! - [if!IE]>开始表单<![endif] - >
< form action =<?php $ _SERVER ['PHP_SELF'];?> id =dataFormname =dataFormmethod =postclass =search_form general_form>
<! - [if!IE]> start fieldset<![endif] - >
< fieldset>
<! - [if!IE]>开始表单<![endif] - >
< div class =forms>

<! - [if!IE]>开始行<![endif] - >
< div class =row>
<?php
$ ckeditor = new CKEditor();
$ ckeditor-> basePath ='ckeditor /';
$ ckeditor-> config ['filebrowserBrowseUrl'] ='ckfinder / ckfinder.html';
$ ckeditor-> config ['filebrowserImageBrowseUrl'] ='ckfinder / ckfinder.html?type = Images';
$ ckeditor-> config ['filebrowserFlashBrowseUrl'] ='ckfinder / ckfinder.html?type = Flash';
$ ckeditor-> config ['filebrowserUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Files';
$ ckeditor-> config ['filebrowserImageUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Images';
$ ckeditor-> config ['filebrowserFlashUploadUrl'] ='ckfinder / core / connector / php / connector.php?command = QuickUpload& type = Flash';
$ ckeditor-> editor('cms_description',urldecode($ ed_about_us));

?>

<! - [if!IE]>开始行<![endif] - >
< div class =row>
< div class =buttons>
< span class =button send_form_btn>< span>< span>提交< / span>< / span>< input type =submitvalue =Submitid =btnSubmit name =btnSubmitonclick =return validate();>< / span>
< / div>
< / div>
<! - [if!IE]>结束行<![endif] - >
< / div>
< / fieldset>

<! - [if!IE]> end fieldset<![endif] - >
< input type =hiddenid =param_actionname =param_actionvalue =

<?php
if(isset($ _ GET ['ed_id ']))
{
echoedit;
}
else
{
echoadd;
} $ b b?>
/>

< input type =hiddenid =cms_idname =cms_idvalue =<?php echo isset($ _ GET ['ed_id'])?$ _ GET ['ed_id ']:;?> />
< / form>

<?php include(tamplate / Template2.php);?>
< h2>关于我们< / h2>
<?php include(tamplate / NewTemplate1.php);?>


< form action =<?php echo $ _SERVER ['PHP_SELF'];?> id =mainFormname =mainFormmethod =post>

<?php include(tamplate / ExtraTemplate.php);?>

< table cellpadding =0cellspacing =0width =100%>
< tbody>
< th style =width:10px;>检查< / th>
< th style =width:450px;>关于我们< / th>
< th style =width:10px;>操作< / th>

<?php

$ get_data = $ con> get_data(select id,about_us from cms order by id);
$ cnt = 1; $ flag ='';

while($ data_row = mysql_fetch_assoc($ get_data))
{
extract($ data_row);
$ cnt%2 == 0?$ flag =second:$ flag =first;
++ $ cnt;

echo< tr class ='$ flag'>;
echo< td>< input type ='checkbox'name ='chk'value ='$ id'>< / td>;
echo< td>。urldecode($ about_us)。< / td>;

echo< td>< div class ='actions'>< ul>< li>< a href ='$ _ SERVER ['PHP_SELF']。 ed_id = $ id'class ='action2'>< / a>< / li>;
echo< li>< a href ='。$ _ SERVER ['PHP_SELF']。?del_id = $ id& table_name = cms& pri = id'onclick ='return deleteSingle ;'class ='action4'>< / a>< / li>< / ul>< / div>< / td>
echo< / tr>;
}
?>

< / tbody>
< / table>
< input type ='hidden'id ='setDel'name ='setDel'/>
<?php include(tamplate / Template3.php);?>
< / form>
<?php include(tamplate / Template4.php);?>
< / body>
< / html>


解决方案

您尝试使用 html_entity_decode()显示内容?它将解码编码的html以获得更好的输出。参考此处



编辑

将您的查询更改为以下



msgctxtName从数据库获取它



urldecode($ value)


$ b b

其中 $ value 是您从数据库获得的块。


I'm using a CKEditor along with a CKFinder. Both work fine. When I browse (or copy directly) an image (or flash) to CKEditor, it's displayed within it and inserted into the MySql database.

Aafter inserting it into MySql database, I'm trying to display it in an HTML table where it isn't displayed and the alternate text is displayed.

The image path after browsing an image through the CKFinder is something like the following.

<img alt="" src="/ckfinder/userfiles/images/1243_SS_2502.jpg" style="width: 490px; height: 618px;" />

The contents inserted into the database is as follows.

&lt;img alt=&quot;\&amp;quot;\&amp;quot;&quot; data-cke-saved-src=&quot;\&quot; 

src=&quot;\&amp;quot;/ckfinder/userfiles/images/1243_SS_2502.jpg\&amp;quot;&quot; st  yle=&

quot;\&amp;quot;width:&quot; 490px;=&quot;&quot; height:=&quot;&quot; 618px;\&quot;= quot;&quot;&gt;

Tried with htmlentities() still it doesn't work. While dealing the same with JSP using JSTL/EL, I had to do the following.

<c:out value="${str}" default="No content found." escapeXml="false"/>

escapeXml="false", where str written in EL was a java.lang.String holding the Oracle clob data after conversion.

What is the way to get around the situation in PHP? Both CKEditor and CKFinder work fine for me.


$ckeditor = new CKEditor();
$ckeditor->basePath = 'ckeditor/';
$ckeditor->config['filebrowserBrowseUrl'] = 'ckfinder/ckfinder.html';
$ckeditor->config['filebrowserImageBrowseUrl'] = 'ckfinder/ckfinder.html?type=Images';
$ckeditor->config['filebrowserFlashBrowseUrl'] = 'ckfinder/ckfinder.html?type=Flash';
$ckeditor->config['filebrowserUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
$ckeditor->config['filebrowserImageUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
$ckeditor->config['filebrowserFlashUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
$ckeditor->editor('description', $ed_about_us);


Edit:

<?php include_once("Lock.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Wagafashion</title>

<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" href="css/template.css" type="text/css"/>
<!--<script type="text/javascript" language="javascript" src="ckeditor/ckeditor.js"></script>-->
<script src="js/jquery-1.6.min.js" type="text/javascript"></script>        
<script src="js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>

<script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script><script>
    jQuery(document).ready(function(){
        // binds form submission and fields to the validation engine
        jQuery("#dataForm").validationEngine();
    });            
</script>

<script language="javascript" type="text/javascript">
    function deleteSingle(id)
    {       
        var delId=confirm("About us with the id "+id+" is about to be deleted permanently.\n\nAttention : This action will never be undone!\n\nAre you sure...???");        
        return(delId==true?true:false);
    }

</script>

</head>

<body>
<?php
    include_once("Connection.php");
    include_once("ckeditor/ckeditor.php");
    $con=new Connection();
    $con->get_connection();

    $ed_about_us="";
    $flag=-1;
    $msg="";

    if(isset($_POST['btnSubmit']))
    {
        $act=trim($_POST['param_action']);
        $about_us=$_POST['cms_description'];        

        if($act=="add")
        {   
            $res=$con->get_data("select count(*) as cnt from cms"); 
            $cnt_cmt=mysql_result($res, 'cnt');

            if($cnt_cmt==0)
            {
                $flag=$con->iud("insert into cms (about_us)values('".mysql_real_escape_string(urlencode($about_us))."')");              
            }
            else
            {
                $flag=$con->iud("update cms set about_us='".mysql_real_escape_string(urlencode($about_us))."'");
            }

            if($flag==1)
            {
                $msg="Insertion done successfully.";        
            }
            else if($flag==0)
            {
                $msg="Insertion failed - reason : ".mysql_errno()." : ".mysql_error();  
            }
        }
        else if($act=="edit")
        {
            $cms_id=$_POST['cms_id'];
            $flag=$con->iud("update cms set about_us='".mysql_real_escape_string(urlencode($about_us))."' where id=".$cms_id."");               
            if($flag==1)
            {
                $msg="About us has been updated successfully.";
            }
            else if($flag==0)
            {
                $msg="Updation failed - reason : ".mysql_errno()." : ".mysql_error();   
            }           
        }
    }           
    else if(isset($_GET['ed_id']))
    {
        $ed_res=$con->get_data("select about_us from cms where id=".$_GET['ed_id'].""); 

        while($row=mysql_fetch_assoc($ed_res))
        {
            $ed_about_us=$row['about_us'];      
        }
    }   
    else if(isset($_GET['del_id']))
    {
        $flag=$con->iud("update cms set about_us='' where id=".$_GET['del_id']);
        if($flag==1)
        {
            $msg="About us been deleted successfully.";
        }
        else if($flag==0)
        {
            $msg="Can not delete - reason : ".mysql_errno()." : ".mysql_error();    
        }
    }
    else if(isset($_POST['btnDelete']))
    {
        $set_del=$_POST['setDel'];
        $flag=$con->iud("update cms set about_us='' where id in($set_del)");
        $size=sizeof(split(",", $set_del));

        if($flag==1)
        {
            if($size==1)
            {
                $msg="1 row deleted.";  
            }
            else
            {
                $msg=$size." rows deleted.";    
            }           
        }
        else if($flag==0)
        {
            $msg="Can not perform deletion - reason : ".mysql_errno()." : ".mysql_error();  
        }       
    }
?>

    <?php include("tamplate/Template1.php");?>
        <h2>About Us</h2>
    <?php include("tamplate/NewTemplate.php");?>

    <?php
        if($flag==1)
        {        
            echo "<p>";
            ?>
                <!--[if !IE]>start system messages<![endif]-->
                <ul class="system_messages">                                     
                    <li class="green"><span class="ico"></span><strong class="system_title"><?php echo $msg; ?></strong></li>                    
                </ul>
                <!--[if !IE]>end system messages<![endif]-->
            <?php               
            echo "</p>";
        }
        else if($flag==0)
        {     
            echo "<p>";
            ?>
                <!--[if !IE]>start system messages<![endif]-->
                <ul class="system_messages">                    
                    <li class="red"><span class="ico"></span><strong class="system_title"><?php echo $msg; ?></strong></li>                                        
                </ul>
                <!--[if !IE]>end system messages<![endif]-->
            <?php               
            echo "</p>";    
        }
    ?>
<img alt=\"\" src="/ckfinder/userfiles/images/1243_SS_2502.jpg" style=\"width: 490px; height: 618px;\" />
      <!--[if !IE]>start forms<![endif]-->
    <form action="<?php $_SERVER['PHP_SELF']; ?>" id="dataForm" name="dataForm" method="post" class="search_form general_form">
        <!--[if !IE]>start fieldset<![endif]-->
        <fieldset>
            <!--[if !IE]>start forms<![endif]-->
            <div class="forms">

            <!--[if !IE]>start row<![endif]-->
            <div class="row">   
            <?php
                $ckeditor = new CKEditor();
                $ckeditor->basePath = 'ckeditor/';
                $ckeditor->config['filebrowserBrowseUrl'] = 'ckfinder/ckfinder.html';
                $ckeditor->config['filebrowserImageBrowseUrl'] = 'ckfinder/ckfinder.html?type=Images';
                $ckeditor->config['filebrowserFlashBrowseUrl'] = 'ckfinder/ckfinder.html?type=Flash';
                $ckeditor->config['filebrowserUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
                $ckeditor->config['filebrowserImageUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
                $ckeditor->config['filebrowserFlashUploadUrl'] = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
                $ckeditor->editor('cms_description', urldecode($ed_about_us));

            ?>             

            <!--[if !IE]>start row<![endif]-->
            <div class="row">
                <div class="buttons">                                                                                                                                                   
                        <span class="button send_form_btn"><span><span>Submit</span></span><input type="submit" value="Submit" id="btnSubmit" name="btnSubmit" onclick="return validate();"></span>                    
                </div>
            </div>
            <!--[if !IE]>end row<![endif]-->
            </div>
        </fieldset>

        <!--[if !IE]>end fieldset<![endif]-->                
        <input type="hidden" id="param_action" name="param_action" value="

            <?php
                if(isset($_GET['ed_id']))
                {
                    echo "edit";        
                }
                else
                {
                    echo "add"; 
                }
            ?>
            " />

            <input type="hidden" id="cms_id" name="cms_id" value="<?php echo isset($_GET['ed_id'])?$_GET['ed_id']:"";?>" />            
    </form>            

    <?php include("tamplate/Template2.php");?>
        <h2>About Us</h2>
    <?php include("tamplate/NewTemplate1.php");?>   


    <form action="<?php echo $_SERVER['PHP_SELF'];?>" id="mainForm" name="mainForm" method="post">                                                

        <?php include("tamplate/ExtraTemplate.php");?>      

            <table cellpadding="0" cellspacing="0" width="100%">
                <tbody>
                <th style="width: 10px;">Check</th>
                <th style="width: 450px;">About Us</th>                
                <th style="width: 10px;">Actions</th>

                <?php

                    $get_data=$con->get_data("select id, about_us from cms order by id");
                    $cnt=1;$flag='';

                    while($data_row=mysql_fetch_assoc($get_data))
                    {
                        extract($data_row); 
                        $cnt%2==0?$flag="second":$flag="first";
                        ++$cnt;

                        echo "<tr class='$flag'>";
                        echo "<td><input type='checkbox' name='chk' value='$id'></td>";
                        echo "<td>".urldecode($about_us)."</td>";

                        echo "<td><div class='actions'><ul><li><a href='".$_SERVER['PHP_SELF']."?ed_id=$id' class='action2'></a></li>";
                        echo "<li><a href='".$_SERVER['PHP_SELF']."?del_id=$id&table_name=cms&pri=id' onclick='return deleteSingle($id);' class='action4'></a></li></ul></div></td>";
                        echo "</tr>";
                    }
                ?>

                </tbody>
            </table>    
            <input type='hidden' id='setDel' name='setDel'/>
            <?php include("tamplate/Template3.php");?>         
    </form>
    <?php include("tamplate/Template4.php");?> 
</body>
</html>

解决方案

Did you try to use html_entity_decode() to display the contents ? It will decode the encoded html for better output. Reference here

Edit
Change your query to the following

insert into cms (about_us) values ('".mysql_real_escape_string(urlecode(stripslashes($about_us)))‌​."')

When you get it from database it use

urldecode($value)

Where $value is the block you got from database.

这篇关于CKEditor和CkFinder在PHP中工作正常,但不显示图像,闪存等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆