(1) 把ueditor文件夹放入Public目录下
(2) 在NewsAction.class.php中加上方法upload()
public function upload() {
import('ORG.Net.UploadFile');
$config = array(
'maxSize' => 2000000, // 上传文件的最大值(2000000表示2M)
'supportMulti' => true, // 是否支持多文件上传
'allowExts' => array('jpg', 'png', 'gif'), // 允许上传的文件后缀 留空不作后缀检查
'autoSub' => true, // 启用子目录保存文件
'subType' => 'date', // 子目录创建方式 可以使用hash datecustom
'dateFormat' => 'Ymd',
'savePath' => './Public/images/school/', // 上传文件保存路径
);
$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)在要应用的模板中(如addnews.html)中加上
<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.οnlοad= function(){
window.UEDITOR_CONFIG.imageUrl= "{:U('upload','','')}"; //访问的方法
window.UEDITOR_CONFIG.imagePath= '__PUBLIC__/Uploads/upimgs/'; //图片上传保存的路径
UE.getEditor('Content');
}
</script>
(4)再把要显示的标签中的id(如:新闻内容中的<textarea>中)的id改为(UE.getEditor('Content');)里面的”Content”