jfinal+ ckeditor4.8 Image Upload

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.