php技术博客
让天下没有搞不定的bug~

修复onethink1.0编辑器图片上传错误

话说这一天onethink1.0正式版正是上线,甚是兴奋,下载一个到本地安装运行,感叹ot功能如此强大的同时暗喜以后做企业站的时候就好弄啦,但是找到了一个问题,编辑器图片上传错误(不论是单张还是批量),不论是切换哪一个编辑器都会出现错误,于是乎分析了下代码,同时在官网找相关的帖子,问题终于解决啦:

后台编辑器:Addons\EditorForAdmin\Controller\UploadController.class.php找到代码:
[codee] /* 上传图片 */
public function upload(){
/* 上传配置 */
$setting = C(‘EDITOR_UPLOAD’);

/* 调用文件上传组件上传文件 */
$this->uploader = new Upload($setting, ‘Local’);
$info = $this->uploader->upload($_FILES);
return $info ? $info : false;
/* update by zone 2014/1/2
if($info){
foreach ($info as &$file) {
$file[‘rootpath’] = __ROOT__ . ltrim($setting[‘rootPath’], “.”);
}

$this->success(‘文件上传成功!’, ”, array(‘files’ => $info));
} else {
$this->error($this->uploader->getError());
}
*/
}

//keditor编辑器上传图片处理
public function ke_upimg(){

/* 返回标准数据 */
$return = array(‘error’ => 0, ‘info’ => ‘上传成功’, ‘data’ => ”);
$img = $this->upload();
/* 记录附件信息 */
/* update by zone 2014/1/2
if($img){
$return[‘url’] = $img[‘fullpath’];
unset($return[‘info’], $return[‘data’]);
} else {
$return[‘error’] = 1;
$return[‘message’] = $this->uploader->getError();
}
*/
/* 记录附件信息 */
if($img){
$img = $img[‘imgFile’];
$return[‘url’] = $this->uploader->__get(‘rootPath’).$img[‘savepath’].$img[‘savename’];
unset($return[‘info’], $return[‘data’]);
} else {
$return[‘error’] = 1;
$return[‘message’] = $this->uploader->getError();
}
/* 返回JSON数据 */
exit(json_encode($return));

}[/codee]

里面代码注释的部分是以前的代码,代码修正后,然后删除缓存文件夹(根目录下的Runtime文件夹),然后刷新试试,这个问题是不是解决了呢,如果前台调用编辑器也会出现这样错误的时候,就修改前台的编辑器所用到的控制器:

前台编辑器:Addons\EditorFor\Controller\UploadController.class.php代码和上边的一样,要学会举一反三额。赶快去尝试一下吧!!

赞(0)
未经允许不得转载:PHP技术博客 » 修复onethink1.0编辑器图片上传错误