我有一个文本区域,它是一个 Ckeditor,但是我包含了 ckfinder,它允许我上传图像。 我需要将文本区域内的所有数据发送到页面来处理接收到的数据。
实际上我无法发送文本区域内的数据。
<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'];
但它是空的。
最佳答案
您需要将其与表格一起提交。并将 ckeditor.js 文件包含在 head 标记中:示例:
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 的一些图像:-) 并添加一些文本,当您提交时,它会在您的 savetextarea.php
关于javascript - 将 CKEditor 与 CKfinder 结合使用并将内容保存到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41726455/