[英]Use CKEditor with CKfinder and save content to the database
我有一個文本區域,它是一個 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'];
但它是空的。
您需要將其與表格一起提交。 並在 head 標簽中包含 ckeditor.js 文件:示例:
索引.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);
當您刷新頁面時,從示例中添加一些圖像:-) 並添加一些文本,當您提交它時,它會在您的savetextarea.php
上顯示內容
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.