Use of the Ueditor editor

Source: Internet
Author: User

(1) Put the Ueditor folder into the public directory

(2) Add method Upload () in NewsAction.class.php

Public function upload () {

Import (' ORG.Net.UploadFile ');

$config = Array (

' MaxSize ' + 2000000,//upload the maximum value of the file (2000000 means 2M)

' Supportmulti ' = true,//Whether multiple file uploads are supported

' allowexts ' = = Array (' jpg ', ' png ', ' gif '),//allow uploading of file suffixes to be left blank without suffix checking

' autosub ' = = true,//enable subdirectory save file

' Subtype ' = ' date ',//subdirectory creation can be made using hash datecustom

' DateFormat ' = ' Ymd ',

' Savepath ' = './public/images/school/',//upload file save path

);

$upload = new UploadFile ($config);

if ($upload->upload ()) {

$info = $upload->getuploadfileinfo ();

Echo Json_encode (

Array

' url ' = = $info [0][' Savename '],

' title ' =>htmlspecialchars ($_post[' Pictitle '), ent_quotes),

' Original ' = $info [0][' name '],

' state ' = ' SUCCESS '

)

);

} else {

echo Json_encode (Array (

' state ' = $upload->geterrormsg ()

));

}

}

(3) in the template to be applied (e.g. addnews.html), add the

<scripttype= "Text/javascript" src= ' __public__/ueditor/ueditor.all.min.js ' ></script>

<script type= "Text/javascript" src= ' __public__/ueditor/ueditor.config.js ' ></script>

<script type= "Text/javascript" >

Window. Ueditor_home_url= ' __public__/ueditor ';

window.onload= function () {

Window.  Ueditor_config.imageurl= "{: U (' upload ', ' ', ')}"; Method of Access

Window.   Ueditor_config.imagepath= ' __public__/uploads/upimgs/'; Image upload saved Path

Ue.geteditor (' Content ');

}

</script>

(4) Change the ID in the label to be displayed (e.g. <textarea> in news content) to (ue.geteditor (' content ');) "content"

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use of the Ueditor 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.