PHP Ueditor Rich Text editor

Source: Internet
Author: User

December 11, 2016 08:46:59 Sunday

Baidu's short version of the Rich text editor Umeditor has not been updated for a long time

Full-featured version of the configuration items with Umeditor or there is a difference, here is how ueditor to receive the project, the main description of how to use the image upload

Html:

1 //Hosting Editor2<script id= "container" name= "content" type= "Text/plain" ></script>3 4 5 //Load JS6<script type= "Text/javascript" charset= "Utf-8" src= "<?= staticurl? >web/ueditor/ueditor.config.js" >< /script>7<script type= "Text/javascript" charset= "Utf-8" src= "<?= staticurl? >web/ueditor/ueditor.all.min.js" > </script>8 9<script type= "Text/javascript" >Ten     //Instantiation Editor One     varUE = Ue.geteditor (' container ', A             { -Initialcontent: ", -initialframewidth:1000, theinitialframeheight:240, -ServerURL: "<?= BASEURL? >home/upload/ueupload", -ImagePath: "",//Path Prefix -             }); +</script>

Note: line 16th, to write your PHP code to access the link, Ueditor will automatically stitching the relevant parameters to indicate what to do:

First step: Ueditor will be stitched up first? Action=config tells PHP to return some configuration information,

Step two: Ueditor get the JSON configuration information returned in the previous step after stitching? action=xxx request a picture upload again

PHP code

1 /**2 * Baidu Ueditor editor call,3 * The corresponding JS configuration item is ServerURL4  */5  Public functionueupload ()6 {7     $arg= I (' get.action ');8     Switch($arg) {9          Case' Config ':Ten             Exit(‘{ One / * Upload picture configuration item * / A "Imageactionname": "Ueuploadimage",/* Perform the action name of the upload picture */ - "Imagefieldname": "Ueupfile", */* submitted picture form name */ - "Imagemaxsize": 2048000,/* Upload size limit, Unit B */ the "Imageallowfiles": [". png", ". jpg", ". jpeg", ". gif", ". bmp"],/* Upload picture format display * / - "imagecompressenable": true,/* whether to compress the picture, the default is true * / - / * Tool upload * / - "Snapscreenactionname": "Ueuploadimage",/* Perform the uploaded action name */ +}‘); -              Break; +          Case' Ueuploadimage '://This value corresponds to the ueuploadimage in the previous case A             $oss=NewUpload (); at             $url=$oss->up (' Ueupfile ', ' ueditor ');//ueupfile corresponds to the ueupfild in the previous case -             if($oss->isok ()) {//Upload Successful -                 $rs= [ -' state ' = ' SUCCESS ', -' url ' = =$url, -' Title ' = ', ' in' Original ' and ' = ' -                 ]; to                 $this->ajaxreturn ($rs); +}Else{//Upload failed -                 $rs= [ the' state ' = ' upload image failed ', *                 ]; $                 $this->ajaxreturn ($rs);Panax Notoginseng             } -              Break; the         default: +             Exit(); A     } the}

Attention:

1. The configuration of lines 12th and 21st corresponds, and the value of line 13th is the name of the form in the uploaded $_files.

2. Note that the 25~30 line is the return structure after the successful upload (to JSON return)

3. Note that the 33~35 line is the return structure after the failed upload (to JSON return)

PHP Ueditor Rich Text editor

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.