1, the front page introduction ckeditor4.8 (official website download)
<textarea rows="10" name="*ckeditor_textarea*" id="texta"></textarea><script type="text/javascript">CKEDITOR.replace("*ckeditor_textarea*");</script>
The name of the textarea is consistent with the replace within the script (CKEditor tutorial is written)
2. Modify ckeditor/congif.js File Configuration
function( config ) { config.image_previewText=‘ ‘//预览区域显示内容"/addPromoteImg?type=Image"//图片上传的 controller(action)};
3, the configuration Contorller method
PublicvoidAddpromoteimg () {StringPath = Pathkit.getwebrootpath (). Replace ("\\","/"); Path = Path.substring (0, Path.indexof ("WebApps")+8)+"promoteimg/";//Promoteimg Save picture Path for customUploadFile file = GetFile ("Upload", Path,5*1024x768*1024x768,"UTF-8");StringImgurl=""; Long fileName = System.currenttimemillis ();if(NULL!=file) {StringSufname = File.getfilename (). substring (File.getfilename (). LastIndexOf ("."), File.getfilename (). Length ());StringImgpath = Path+file.separator+filename+sufname; File dest =NewFile (Imgpath); Imgurl="/promoteimg/"+filename+sufname; File.getfile (). Renameto (dest);StringCallback =getpara ("Ckeditorfuncnum"); PrintWriter writer =NULL;Try{HttpServletResponse response = GetResponse (); writer = Response.getwriter (); Writer.write ("<script type=\" text/javascript\ "> "+"Window.parent.CKEDITOR.tools.callFunction ("+ Callback +", '"+address+ FileName + sufname+"', ')"+"</script>"); Writer.flush (); }Catch(IOException e) {Throw NewRenderexception (e); }finally{if(Writer! =NULL) Writer.close (); }} rendernull (); }
jfinal+ ckeditor4.8 Image Upload