2017-01-18 75 views
1

我有一个textarea,它是一个Ckeditor,但是我包含了允许我上传图像的ckfinder。 我需要将textarea内的所有数据发送到页面以处理收到的数据。使用CKEditor和CKfinder并将内容保存到数据库中

其实我无法发送textarea里面的数据。

 <label>Corpo da Instrução de Trabalho</label> 
     <textarea name="editor1" id="editor1" rows="10" cols="80" placeholder="Escrever o conteúdo da IT aqui..."> 

     </textarea> 

     <script> 

     // Replace the <textarea id="editor1"> with a CKEditor 
     // instance, using default configuration. 

    // CKEDITOR.replace('editor1'); 

    var editor = CKEDITOR.replace('editor1'); 
    CKFinder.setupCKEditor(editor); 

    </script> 

当我试图挽救其上接收到数据文件中的数据我做这样的事:

$myText = $_POST['editor1']; 

但它是空的。

回答

0

您需要将其与表单一起提交。并包括头标记ckeditor.js文件:例如:

的index.php

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <meta name="robots" content="noindex, nofollow"> 
    <title>Classic editor replacing a textarea</title> 
    <script src="http://cdn.ckeditor.com/4.6.2/standard-all/ckeditor.js"></script> 
</head> 

<body> 
    <form action="savetextarea.php" method="post" > 

    <textarea cols="80" id="editor1" name="editor1" rows="10"> 
    </textarea> 

     <p> 
      <input type="submit" value="Submit"> 
     </p> 
    </form> 

    <script> 
     // CKEDITOR.replace('editor1'); 
    var editor = CKEDITOR.replace('editor1'); 
    CKFinder.setupCKEditor(editor); 
    </script> 
</body> 

</html> 

在同一个文件夹中创建savetextarea.php,不要忘了打印出来的内容:

<?php 

$my_text = $_POST['editor1']; 
print_r($my_text); 

当您刷新页面从example :-)添加一些图像,并添加一些文字,当您提交它,它会显示在您的内容210

+0

我已经完成了你所说的。但是在我的savetextarea.php中,$ _PosT [''editor1']不存在。 –

+0

你的意思是它不会显示在你的savetextarea.php中?尝试我发布在单独的文件中的示例,它的工作原理。一行一行,并与您的代码进行比较。检查是否包含CK库,并在savetextarea.php上需要显示ckeditor。你是否在同一页面提交你的表单?从没有CKeditor的简单事情开始。试试简单的PHP表单,看看你是否有任何输出。如果你有,那么你可以移动到ckeditor实现。如果你有完整的例子,通过http://pastebin.com发送给我,并在这里分享,我会解决它 – Blackcoat77

相关问题