準備
CKEditor&&CKFinder破解版百度網盤地址:http://pan.baidu.com/s/1qWsDPKC 密碼:yydcdut
將CKEditor和CKFinder放在同一文件夾下。
CKEditor實現編輯框
CKEditor 實際是替換一個textarea標簽,所以把textarea放到一個form表單中,當提交到php服務器端,使用$_POST['xxx'] 取得編輯好的數據。
修改CKEditor的配置文件config.js
1 CKEDITOR.editorConfig = function( config )2 {3 config.language = 'zh-cn';4 config.uiColor = '#FFA';5 config.skin = 'v2';6 config.width = 850;7 config.height = 400;8 config.toolbar = 'Full';9 };
一個簡單的網頁實現
1 <html> 2 <head> 3 <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> 4 <title>yyd</title> 5 </head> 6 <body> 7 <form action="post.php" method="post"> 8 <textarea name="editor1">yyd</textarea> 9 <input type="submit" name="submit" value="Submit" />10 </form>11 </body>12 13 <script src="ckeditor/ckeditor.js"></script>14 <script type="text/javascript">15 // 啟用 CKEitor 的上傳功能,使用了 CKFinder 插件16 CKEDITOR.replace( 'editor1', {17 filebrowserBrowseUrl : 'ckfinder/ckfinder.html',18 filebrowserImageBrowseUrl : 'ckfinder/ckfinder.html?Type=Images',19 filebrowserFlashBrowseUrl : 'ckfinder/ckfinder.html?Type=Flash',20 filebrowserUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',21 filebrowserImageUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',22 filebrowserFlashUploadUrl : 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'23 });24 </script>25 </html>
實現截圖
CKFinder實現上傳圖片
第21行的函數
1 function CheckAuthentication() 2 { 3 // WARNING : DO NOT simply return "true". By doing so, you are allowing 4 // "anyone" to upload and list the files in your server. You must implement 5 // some kind of session validation here. Even something very simple as... 6 7 // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized']; 8 9 // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the10 // user logs in your system. To be able to use session variables don't11 // forget to add session_start() at the top of this file.12 13 //return false;14 return true;15 }
第66行,即修改為創建的uploads路徑
1 $baseUrl = '/CK/plugins/uploads/';
實現截圖
創建post.php文件,將傳遞過來的POST打印出來
1 <?php2 header("Content-Type:text/html; charset=utf-8");3 $str = $_POST['editor1'];4 $data = stripslashes(htmlspecialchars_decode($str));5 echo $data;6 ?>
總結和問題的解決
當我配置完成后,submit提交之后死活都不能顯示圖片,查看源代碼的時候,發現雙引號被轉義了,覺得很蛋疼。我不知道這個CKEditor轉義的還是瀏覽器轉義的,因為就在前幾天,我在測試SQL注入的時候就發現明明可以注入的,但死活不出來結果,然后在本機上將passWord傳遞過去的值打印出來了,發現是被轉義了,表示很蛋疼。所以我在這里用了$data = stripslashes(htmlspecialchars_decode($str));將轉義之后再反轉義湖區,結果就OK了。
CKEditor&&CKFinder組合不僅可以上傳圖片,還可以上傳文件等。
轉載請注明出處:http://www.companysz.com/yydcdut/p/3518102.html
新聞熱點
疑難解答